Skip to content

Keep legacy query preparation in replay mode - #1658

Merged
Sushisource merged 6 commits into
mainfrom
fix/legacy-query-replay
Oct 20, 2026
Merged

Sushisource merged 6 commits into
mainfrom
fix/legacy-query-replay

Conversation

@Sushisource

@Sushisource Sushisource commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

What was changed

  • Stay replaying while preparing to serve a legacy query, including when its history contains trailing events or an already-started workflow task. Local activities without recorded results remain pending instead of executing during query playback.
  • Notify pending local activities at one point after history application and marker lookahead, allowing the next real workflow task to execute them without evicting the cached run.

Why?

Legacy queries cannot produce workflow commands. Previously, reaching the end of query history could end replay and dispatch local activities whose commands were discarded. This could duplicate side effects and leave cached runs in an invalid state or stuck. Query preparation must remain replay-only while preserving the cache for the next real workflow task.

Checklist

  1. Closes [Bug] Legacy query task executes local activities; the cached run can then hit "invalid state MarkerCommandCreated" or wedge #1644

  2. How was this tested:

    • timeout 180 cargo integ-test workflow_tests:: — 357 passed, 1 ignored; includes the four regression cases and recorded-marker replay tests.
    • cargo test -p temporalio-sdk-core --lib — 492 passed, 2 ignored.
    • timeout 180 cargo integ-test legacy_query — 10 passed with the ephemeral server before the final notification-site refactor; the subsequent workflow test run covers that refactor.
    • After moving to origin/main: timeout 180 cargo integ-test --server-kind external legacy_query_must_not_execute_local_activity — all four cases passed; this test uses mocked server responses.
    • cargo lint, cargo +nightly fmt, and git diff --check passed. Lint and diff checks were rerun on the new base.
  3. Any docs updates needed?

    • Added user-facing entries under Unreleased in both changelogs. No public API or additional documentation changes are needed.

.to_path_buf()
// Shared build caches can reuse a runner compiled in another worktree. Cargo's runtime
// manifest directory identifies the checkout being tested, unlike the compiled-in path.
let manifest_dir = env::var_os("CARGO_MANIFEST_DIR")

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.

Nice

#[allow(clippy::large_enum_variant)]
enum WFCommandVariant {
/// Returned when we need to wait for the lang sdk to send us something
NoCommandsFromLang,

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.

For self: why?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just wasn't doing anything useful any more

Comment on lines +577 to +583
} else if results.iter().any(|cmd| {
!matches!(
&cmd.variant,
WFCommandVariant::UpdateResponse(response)
if matches!(response.response, Some(update_response::Response::Rejected(_)))
)
}) {

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.

Not that humans read code anymore, but a comment (or switching to an all vs negated any bc that makes more sense in my brain for some reason) explaining the condition we're checking would help.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

My hope here was the returned error clarifies stuff - it's just looking for anything that isn't a rejected update.

Comment on lines -281 to -283
panic!(
"Got a new WFT while there are outstanding local activities, but there \
was no waiting on LA info."

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.

Self: not fully understanding why this is no longer a concern

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's now possible that we might want to start an LA during replay while servicing a query, but, we don't dispatch it because we're servicing a query and not a new task.

Then, we might get a real task, at which point we now can in fact dispatch that LA for execution. So, there was no waiting on la info at that point (but there will be after we dispatch it)

@Sushisource
Sushisource force-pushed the fix/legacy-query-replay branch from 254769c to 013dec1 Compare October 20, 2026 16:13
@Sushisource
Sushisource enabled auto-merge (squash) October 20, 2026 16:13
@Sushisource
Sushisource merged commit 829eb7e into main Oct 20, 2026
24 checks passed
@Sushisource
Sushisource deleted the fix/legacy-query-replay branch October 20, 2026 16:31
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] Legacy query task executes local activities; the cached run can then hit "invalid state MarkerCommandCreated" or wedge

2 participants