Repository navigation
Wait until the Activity worker finishes shutting down - #3224
Open
litlep-nibbyt wants to merge 4 commits into
Open
litlep-nibbyt wants to merge 4 commits into
litlep-nibbyt wants to merge 4 commits into
Conversation
litlep-nibbyt
marked this pull request as ready for review
November 18, 2026 01:07
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?
NoopWorker.awaitTermination()now waits forNoopWorker.shutdown()or the caller’s timeout. ACountDownLatch(1)records shutdown and releases any waiting threads.Why?
A worker with no registered Activities uses
NoopWorkeras its Activity poller. The placeholder has no tasks or threads of its own, but the SDK still tracks whether it has been shut down.When the Activity worker stops heartbeats first, the SDK calls
NoopWorker.shutdown()in a later step. The old empty wait letWorkerFactory.awaitTermination()return between those steps, with time still left andisTerminated()still false.Before and after
Earlier attempts
Previous proposals changed the workflow worker or the worker factory. Review feedback questioned whether their tests demonstrated the reported problem.
This proposal addresses a different component and tests the failure through real workers and executors.
Validation
Worker.awaitTermination()waits for the Activity, Nexus, and Workflow sides in that order, using the time left from the same timeout.Branch 3 still waits for the real Workflow poller and task executor.
One existing test was verified fixed:
StickyWorkflowDrainShutdownTest.testShutdownNow[1], the autoscaling variant. It failed 5/5 times before the fix and passed 5/5 with the latch under the same controlled delay. The other three sticky cases also passed in CI. Cloud CI logThree new regression tests also failed against our first implementation and passed with the latch:
NoopWorkerTest.awaitTerminationWaitsForShutdownSyncActivityWorkerTest.awaitTerminationBeforeShutdownWaitsForHeartbeatShutdownContinuationSyncActivityWorkerTest.gracefulAwaitTerminationBeforeShutdownWaitsForHeartbeatShutdownContinuationRegression tests also cover waiting before and after shutdown, timeout, and interruption.
Across the local test runs, 78 tests passed and one skipped because the server lacked a required capability. The unchanged shutdown test passed 100 runs without the deliberate delay. The cause of the historical CI failures remains unconfirmed.
Breaking changes: None.
Documentation: Changelog entry included.
Server changes: None.