Skip to content

Add shutdown_worker_rejected field to poll responses#9551

Draft
rkannan82 wants to merge 4 commits intomainfrom
kannan/poll-shutdown-rejected-field
Draft

Add shutdown_worker_rejected field to poll responses#9551
rkannan82 wants to merge 4 commits intomainfrom
kannan/poll-shutdown-rejected-field

Conversation

@rkannan82
Copy link
Contributor

What changed?

  • Add shutdown_worker_rejected bool field to matching-internal poll response protos (workflow, activity, nexus).
  • Refactor pollTask to return a pollResult struct instead of bare (*internalTask, bool, error), carrying a shutdownRejected flag.
  • When the shutdown worker cache rejects a poll, the flag is set on the matching-internal response.
  • TODOs added in frontend handler for propagating the field to the public API once go.temporal.io/api is 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?

  • built
  • covered by existing tests (updated pollTask callers in unit tests)
  • functional test assertion on the field (pending api dep bump)

Potential risks

None — additive proto field, backward compatible. pollResult refactor is internal to the matching engine.

Made with Cursor

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
…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
Base automatically changed from kannan/shutdown-worker-poll-rejection to main March 23, 2026 17:17
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.

1 participant