Skip to content

fix(core): preserve buffered queries across run eviction - #1693

Merged
Sushisource merged 3 commits into
temporalio:mainfrom
mbackschat:fix/preserve-buffered-queries-1621
Oct 22, 2026
Merged

Sushisource merged 3 commits into
temporalio:mainfrom
mbackschat:fix/preserve-buffered-queries-1621

Conversation

@mbackschat

Copy link
Copy Markdown
Contributor

Fixes #1621.

When eviction completes with multiple same-Run Query tasks buffered, Core reinstantiates the Run from the first task and discards the rest. Preserve the remaining tasks by transferring them into the replacement Run in buffer insertion order, retaining the existing Workflow Task supersession groups. If the first task needs a history fetch, retain the activation produced by a later task with full history.

Regression coverage queues one, two and three Queries during completion eviction with cache capacities 0, 1 and 10 (within their slot limits), using full or mixed history and optionally starting shutdown before acknowledging eviction. A channel barrier ensures all Queries are buffered before eviction proceeds. The test checks each Query is delivered once, all responses reach the client mock, shutdown completes and workflow-task permits are returned. Separate tests guard Query-group preservation when a buffered Workflow Task is superseded.

This transfers already accepted tasks; it does not change polling limits or add a drain loop. Preserved Queries retain their slots until serviced or otherwise released, so shutdown can wait longer than when they were discarded. The tests cover a finite queue with completed handlers, not a shutdown-latency guarantee for unresponsive handlers.

Validation on macOS arm64 against upstream 0a5d6462:

  • Before the fix: all 20 multi-Query cases fail; all 12 one-Query controls pass.
  • With the fix: complete Core library suite passes, 533 tests with one existing ignored coverage reporter, including all 32 eviction cases and four supersession cases.
  • cargo lint, cargo test-lint and formatting pass.
  • cargo integ-test --server-kind external workflow_tests::queries -- --test-threads=2: all six existing SDK Query tests pass (mock-server tests).

Eviction must not discard accepted queries when the replacement run is created. Preserve supersession groups and retain the activation produced by a later task while the first waits for history.
@mbackschat
mbackschat requested a review from a team as a code owner October 21, 2026 06:18
@CLAassistant

CLAassistant commented Oct 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Sushisource Sushisource left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Love the simplicity.

@@ -0,0 +1,80 @@
use super::{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be reasonable to just have this be in the test mod at the bottom of the parent module instead of a new file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! Moved the tests into the parent module’s test mod as suggested.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Looks like it just needs some merge conflict resolution w/ the changelog.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved. I moved the Rust SDK changelog entry to the new fragment format.

@Sushisource
Sushisource enabled auto-merge (squash) October 21, 2026 21:45
Upstream now records pending Rust SDK changes as release fragments. Preserve the reviewed fix and Core entry while moving the SDK note into the new format.
auto-merge was automatically disabled October 22, 2026 00:40

Head branch was pushed to by a user without write access

@Sushisource
Sushisource enabled auto-merge (squash) October 22, 2026 16:23
@Sushisource
Sushisource merged commit b16e808 into temporalio:main Oct 22, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Core drops buffered Queries when it evicts a Run that has more than one queued

3 participants