Repository navigation
Commit 328fb87
Release in-flight jobs when the async supervisor's shutdown times out
When a job outlives shutdown_timeout during graceful termination, the
async supervisor ends with exit!, which skips the shutdown callbacks:
neither the supervisor nor its threads deregister, and their claimed
jobs stay claimed until a later supervisor prunes the stale
registrations and fails them with ProcessPrunedError. On a TERM, which
is what deploys send, the job is failed instead of going back to its
queue as it does in fork mode.
Worse, the supervisor and each worker wait for that same timeout, the
supervisor starting slightly earlier, so it usually runs out first and
calls exit! while the worker is still inside its own deregistration
transaction, rolling back the release it had started.
When the timeout runs out with threads still alive, deregister the
supervisor before exit!, as the fork supervisor does after quitting its
forks: the threads still running are deregistered with it and their
claimed jobs go back to their queues. Deregister from a fresh copy of
the registration, since the threads share theirs with the supervisor's
in memory and a thread that already deregistered leaves a frozen record
behind.
QUIT is unchanged: it still exits without cleanup, as the async
lifecycle test documents.
The async lifecycle test for TERM past the timeout now expects the
in-flight job back in its queue and a clean termination, like its fork
counterpart, instead of accepting either outcome.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>1 parent ec42a7e commit 328fb87
2 files changed
Lines changed: 19 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
47 | 61 | | |
48 | 62 | | |
49 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
184 | 181 | | |
185 | 182 | | |
186 | 183 | | |
| |||
0 commit comments