Repository navigation
Conversation
moetemp
marked this pull request as ready for review
November 16, 2026 04:34
The propagation helper returned a bool to `assert_eventually`, which only retries on an assertion, so it never waited. Five tests also started a Workflow right after setting the current version, when the task queue could still route to the old one.
On the time-skipping server the child inherits time skipping, so its 1000 s sleep fires about a second after it starts. The child now waits on a condition that only a cancel ends.
A Signal that shares a Workflow Task with the child's start runs its handler before `run` resumes, so the handler found no child yet. The test waited only for the child to exist.
moetemp
force-pushed
the
moe/fix-flaky-worker-shutdown-tests
branch
from
November 16, 2026 17:14
c570a44 to
78a6bbb
Compare
The server can miss a poll that comes right after `ShutdownWorker`. The Worker then waits until that poll expires, about a minute by default, and the test times out.
moetemp
added a commit
to temporalio/temporal
that referenced
this pull request
Nov 17, 2026
…k queue (#13116) ## What changed? This PR makes matching record a Worker as shut down before the poll cancellation fan-out, so that a poll that arrives later is refused at once. Fixes #13114 ## Why? A Worker that shuts down right after its start can send `ShutdownWorker` while its first poll is still on its way. Matching skips the fan-out when the root partition isn't loaded, and it didn't record the Worker in `shutdownWorkers`. The late poll was then accepted and stayed open for 50 to 60 seconds. An SDK that waits for the server to end its polls took that long to shut down. Related: temporalio/sdk-rust#1802 and temporalio/sdk-python#2133. ## How did you test it? - [x] built - [ ] run locally and tested manually - [ ] covered by existing tests - [x] added new unit test(s) - [x] added new functional test(s) Both new tests shut a Worker down for an unloaded task queue and then poll with the same key. In the functional test the poll took 59.9s without the fix, and 0.06s with it. ## Potential risks `shutdownWorkers` is local to each matching host. So a poll that lands on a partition of another host is still accepted. One matching host, as in the dev server, is fully covered.
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?
This PR removes races from the Worker and Workflow tests.
matching.longPollExpirationInterval).Why?
Each one is a flaky test in CI.
test_worker_with_worker_deployment_configfails incloud-test. Its Workflow starts before the new current version is routed.test_workflow_cancel_multiandtest_workflow_cancel_child_startedfail on the time-skipping server. It skips the child's 1000 s sleep, and the cancel Signal can arrive before the parent holds the child.test_warns_when_workers_too_lowandtest_worker_fatal_error_withtime out when the server misses a poll that comes right afterShutdownWorker. The Worker then waits until that poll expires, about a minute by default. The fix for that is in the server (temporalio/temporal#13116). The shorter expiration only keeps such a shutdown fast in the tests, and it doesn't apply tocloud-test.How did you test it?
For the child-cancel tests I reproduced each cause on its own, and each test fails before the change and passes after. The routing race shows only against Temporal Cloud, so the
cloud-testjob is its check.Link to a test plan if any -