[SDK Sentinel] Fix WorkerFactory shutdown await race - #3093
Open
sdk-sentinel-bot wants to merge 1 commit into
Open
sdk-sentinel-bot wants to merge 1 commit into
sdk-sentinel-bot wants to merge 1 commit into
Conversation
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.
Caution
This PR contains untrusted AI-generated code. Do not approve or run CI until a maintainer has reviewed the diff. SDK Sentinel verified that GitHub Actions remained approval-gated with zero executable jobs when this PR was opened.
Summary
Prevent
WorkerFactory.awaitTerminationfrom returning before asynchronous worker shutdown completes. The [first captured Edge failure](https://github.com/temporalio/sdk-java/actions/runs/35512726248/job/106083372368) affected the autoscaling sticky-poller variant; no preceding equivalent success was available.Root cause
Poller shutdown and task-executor shutdown became sequential future stages.
awaitTerminationcould observe the poller as terminated before its continuation initiated task-executor shutdown, then return while the factory remained active.Fix
Retain the aggregate shutdown future and await it using the caller's remaining timeout. Extend the lifecycle regression test to require this additional wait. There are no API, replay, workflow-history, breaking, or server changes.
Validation
The regression suite and both shutdown-now poller variants pass on Temurin JDK 23. Formatting and all test classes compile. The unchanged canonical baseline passed, but candidate canonical validation was blocked by sandbox ownership of Gradle and Git submodule metadata. The Edge JDK 23 job and canonical validator remain required.
Validation status:
validation-incompletehighhighmediumstandard— 2 changed files; 3.8 KiBnot-reproduced— One unchanged focused run passed on Temurin JDK 23.0.2; the captured timing, parameter contrast, and asynchronous shutdown chain exposed the race causally.pass-after-only— The regression assertion verifies that awaitTermination waits both the command worker and aggregate asynchronous shutdown chain; it and the original failing test pass after the fix.Gradle formatting and test-source compilation) — passedGradle formatting and test-source compilation) — did not pass (failure)Investigator-run checks
GRADLE_USER_HOME=.ci-flake-runtime/tmp/gradle-home ./gradlew --offline --no-daemon :temporal-sdk:test -x :temporal-serviceclient:updateSubmodules -x :temporal-sdk:compileJava17Java --tests 'io.temporal.worker.shutdown.StickyWorkflowDrainShutdownTest.testShutdownNow*'— passed; 1 attempt(s). The unchanged test passed locally on Temurin JDK 23.0.2; natural reproduction did not occur.GRADLE_USER_HOME=.ci-flake-runtime/tmp/gradle-home ./gradlew --offline --no-daemon :temporal-sdk:test -x :temporal-serviceclient:updateSubmodules -x :temporal-sdk:compileJava17Java --tests 'io.temporal.worker.WorkerShutdownTest' --tests 'io.temporal.worker.shutdown.StickyWorkflowDrainShutdownTest.testShutdownNow*'— passed; 1 attempt(s). The final candidate passed the regression suite and both shutdown-now poller variants..ci-flake-runtime/input/validate.sh— failed; 2 attempt(s). The trusted unchanged baseline passed. Candidate attempts were sandbox-blocked by the root-owned Gradle daemon registry and read-only Git submodule metadata before patch compilation.GRADLE_USER_HOME=.ci-flake-runtime/tmp/gradle-home ./gradlew --offline --no-daemon spotlessCheck testClasses -x test -x :temporal-serviceclient:updateSubmodules -x :temporal-sdk:compileJava17Java— passed; 1 attempt(s). The permitted equivalent formatting and test-compilation check passed for all modules.Required target CI
Residual risks
Automation provenance
b250876f6bdb7d11049f684cf8583d0e7940d8cdIf this finding should not be fixed, apply the
sdk-sentinel:false-positivelabel and close the PR. Sentinel will suppress the finding until its affected source changes.SDK Sentinel recurrence history
2026-09-20 13:21 UTC2026-09-20 13:21 UTC