Add shutdown_worker_rejected field to poll responses#9551
Draft
Add shutdown_worker_rejected field to poll responses#9551
Conversation
When ShutdownWorker cancels a worker's polls via CancelOutstandingWorkerPolls, the SDK's graceful shutdown path may re-poll before fully stopping. This zombie re-poll can sync-match with retry tasks (e.g., activity retries dispatched by the timer queue), which the dying worker silently drops — causing the task to sit until timeout. Add a TTL cache of recently-shutdown WorkerInstanceKeys to the matching engine. Polls arriving from workers in this cache are rejected immediately with an empty response, preventing zombie re-polls from stealing tasks. Made-with: Cursor
…protos Made-with: Cursor
…hutdown workers Refactor pollTask to return a pollResult struct carrying the task, versionSetUsed, and a shutdownRejected flag. When the shutdown cache rejects a poll, the flag is set and propagated to the matching-internal poll response. Frontend propagation of the field to the public API is pending an api dependency bump. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
shutdown_worker_rejectedbool field to matching-internal poll response protos (workflow, activity, nexus).pollTaskto return apollResultstruct instead of bare(*internalTask, bool, error), carrying ashutdownRejectedflag.go.temporal.io/apiis bumped.Why?
SDKs currently cannot distinguish between an empty poll response from a normal timeout vs. one caused by shutdown rejection. This field gives SDKs an explicit signal to stop re-polling.
Depends on API PR: temporalio/api#730
How did you test it?
pollTaskcallers in unit tests)Potential risks
None — additive proto field, backward compatible.
pollResultrefactor is internal to the matching engine.Made with Cursor