Skip to content

fix(durable): keep await deadlines independent of status polls - #4508

Merged
juruoO-o merged 2 commits into
agentscope-ai:mainfrom
pengmoubuaixuexi:fix/durable-await-deadline-4507
Dec 2, 2026
Merged

juruoO-o merged 2 commits into
agentscope-ai:mainfrom
pengmoubuaixuexi:fix/durable-await-deadline-4507

Conversation

@pengmoubuaixuexi

@pengmoubuaixuexi pengmoubuaixuexi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Fixes #4507. A blocked status read can occupy the observer pool and prevent DurableTurn.await(timeout) from settling. An inline timeout callback can also stall subsequent waits if it runs on the deadline scheduler.

Use a Runtime-owned deadline scheduler to dispatch timeout completions to a separate elastic executor. The elapsed wait completes exceptionally with a TimeoutException containing its Thread/Turn identity. Status polling stays on the observer pool. Runtime close shuts both new executors down. An admitted Turn can still be queried after the wait ends.

The two regressions cover a blocked backend poll and an earlier non-async completion callback held on a latch. In both scenarios the wait times out while the blockage is held.

Verification

  • The blocked-read and blocked-callback regressions fail on main at 9cfeaad. The blocked-callback case also fails on the previous PR head d5fccbe, which completed directly on its deadline thread.
  • Ran mvn -B -T1C -pl agentscope-durable/durable-runtime -am clean verify on the updated branch. All 50 tests passed without skips on Windows/Java 17.
  • The targeted Harness test that previously timed out in Windows CI passed all ten parameter sets on this head. Full repository checks are running again in CI.
  • Spotless, git diff checks, all 20 documentation tests, and Mintlify validation passed. The link checker reported the same 2,754 source/target entries on main and this branch.

AI assistance was used for investigation, implementation, and verification.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments follow project conventions
  • Related documentation has been updated
  • Code is ready for review

Copilot AI balanced review requested due to automatic review settings November 30, 2026 00:07
@mintlify

mintlify Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit a558cc4.

Approve preview

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@pengmoubuaixuexi

Copy link
Copy Markdown
Contributor Author

Windows CI follow-up for d5fccbe9: the Durable Runtime module passed all 49 tests, including the new blocked-poll regression. The Windows job later stopped in Harness when parameter set [5] of HarnessContextRegressionTest.backgroundResultSurvivesCompactionAndIsDeliveredOnce hit its existing 15-second blocking-read timeout. The Ubuntu job passed.

On Windows with Temurin 17, all ten parameter sets of that Harness test passed on the PR head and on base 816f98ff. The same targeted run on the PR head also passed all three DurableRuntimeTest cases. These focused runs did not reproduce the full CI timeout. Harness source and tests are unchanged by this branch.

Could a maintainer rerun the failed Windows job? The contributor account has read access to the upstream repository. The PR head and test assertions are unchanged.

@juruoO-o

juruoO-o commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

The separate deadline executor fixes starvation from blocked status reads, but a blocked completion can still starve unrelated deadlines. The single deadline thread calls result.completeExceptionally(...) directly. Non-async CompletableFuture dependents (e.g. a caller’s whenComplete) may run inline on that thread, as can the internal notification.close() callback. If the first timeout blocks there, a second await cannot expire on time. Could we keep potentially blocking completion work off the deadline scheduler and add a test that holds the first timeout callback on a latch while asserting that a second await expires before the latch is released?

@pengmoubuaixuexi

Copy link
Copy Markdown
Contributor Author

Thanks @juruoO-o. I reproduced the callback starvation on the previous PR head. A non-async callback held the only deadline thread on a latch, and the second await was still pending when its outer get timed out.

The updated head a558cc4 merges current main (9cfeaad) and keeps the timer limited to dispatching timeout completions. Completions run on a Runtime-owned elastic executor, isolated from status reads and other timeout callbacks. Both executors are shut down by the Runtime. The new test verifies the second await times out while the first callback is still blocked, and the original blocked-read regression still passes.

The Durable Runtime build passed all 50 tests on Windows/Java 17, and documentation validation passed. Fresh Linux and Windows CI is running on the updated branch, so the previous request to rerun the old head is superseded.

@juruoO-o juruoO-o left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The timer now dispatches timeout completion to a separate elastic executor. The latch tests cover a blocked status read and a blocked synchronous completion callback while a second await expires. Both executors participate in runtime shutdown. Ubuntu and Windows CI passed.

@juruoO-o
juruoO-o merged commit bbc292a into agentscope-ai:main Dec 2, 2026
7 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]: DurableTurn.await timeout can be blocked by its status poll

3 participants