Skip to content

Fix queries buffered during Continue-As-New - #3166

Closed
danikhan-oai wants to merge 2 commits into
temporalio:mainfrom
danikhan-oai:codex/temporal-query-continue-as-new-20261026
Closed

danikhan-oai wants to merge 2 commits into
temporalio:mainfrom
danikhan-oai:codex/temporal-query-continue-as-new-20261026

Conversation

@danikhan-oai

@danikhan-oai danikhan-oai commented Oct 27, 2026 •

Copy link
Copy Markdown

A strongly consistent query can be buffered while a workflow task completes Continue-As-New. The test server can then try to schedule another workflow task on the closed run. The completion fails with NOT_FOUND: workflow execution already completed, and the query waits until its deadline.

Use isTerminalState() for the workflow-task rescheduling guard so Continue-As-New commits the old run's history before buffered queries dispatch. Register each buffered query result future before sendQueryTask so an immediate response can find it.

The regression test uses a latch to confirm the query is buffered before Continue-As-New completes. It responds synchronously during dispatch and verifies that the query remains bound to the original run, receives its committed close event, and does not prevent the new run from starting.

Testing

  • Verified the regression fails on parent commit 3fb41a5a28b94fe7a150105901b626ba259fa050 with NOT_FOUND: workflow execution already completed.
  • Verified the terminal-state change alone exposes the second race with NOT_FOUND: Unknown query id.
  • Verified the complete fix passes the regression, including 10 repeated runs that force the race ordering.
  • Ran the complete temporal-test-server module suite: 98 passed, 1 existing ignored test tracked by taskTimeoutWillRescheduleTheTaskOnTheGlobalList on the test server is flaky #2333, 0 failed.
  • Relevant Spotless checks and git diff --check passed.
  • Built the JVM :temporal-test-server:installDist distribution.

The source test results above apply to commit 1257ea83d43916fee9ce071fd6b9317d5bf1c077. The follow-up commit only adds the required changelog entry, which passed the local placement check.

The complete repository test suite and native image build were not run.

Treat Continue-As-New as terminal when deciding whether to schedule a
new workflow task on the current run. This lets the old history commit
before buffered queries dispatch.

Register each query future before dispatch so an immediate worker
response can resolve it.

Add a regression test that buffers a query during Continue-As-New,
responds during dispatch, and verifies the query stays on the closed run.
@danikhan-oai
danikhan-oai requested a review from a team as a code owner October 27, 2026 00:08
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants