Repository navigation
Conversation
Keep the shared command poller available while regular workers drain. On supported namespaces, ask the server to complete the outstanding poll so graceful shutdown can finish without interrupting it.
Keep both changelog entries after main added the workflow poller balancing fix.
Give each command poller a distinct instance key so shutting down one factory does not suppress polls from another factory on the same client.
Use the RPC outcome to fall back to interrupting the command poll. This lets factory shutdown proceed without waiting for the long poll to expire when the server cannot complete it.
yuandrew
marked this pull request as ready for review
November 24, 2026 22:18
This branch has not been deployed
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?
Keep the shared worker-command poller running while the factory's regular workers drain. On namespaces that support graceful poll completion, send
ShutdownWorkerfor the command queue so the server can complete the outstanding Nexus poll.shutdownNow()and namespaces without the capability still interrupt the poll.Why?
Activities can still receive worker commands during the drain. The Go SDK fixed the same shutdown issue in temporalio/sdk-go#2907.
Testing
Added an in-process gRPC regression test that holds an activity open, observes a second command poll during shutdown, verifies the shutdown request targets that poll, and checks that the factory terminates without interrupting it.
The focused Java shutdown suite passed 35 tests. Three tests that require an external Temporal server were skipped.
Compatibility
Uses the existing
ShutdownWorkerRPC. No public API changes or companion server PR.Closes #3234.
Note
Medium Risk
Changes worker factory shutdown ordering and Nexus poll teardown; incorrect behavior could block command delivery during drain or leave polls stuck, though graceful paths are gated on namespace capability and RPC failure falls back to interrupt.
Overview
Fixes graceful
WorkerFactory.shutdown()so the shared worker-command Nexus poller stays up while regular workers drain activities, instead of being torn down immediately.When the namespace supports graceful poll completion,
WorkerFactorydefers stopping the command worker until other workers finish;NexusWorkersendsShutdownWorkerfor the command queue (with a per-factory randomworkerInstanceKeyso instances shut down independently) and only falls back to interrupting the poll if that RPC fails.ShutdownManagernow exposes whether the shutdown RPC succeeded.Adds in-process regression tests and a CHANGELOG fix note.
Reviewed by Cursor Bugbot for commit 24bf67e. Bugbot is set up for automated code reviews on this repo. Configure here.