Skip to content

Replace terminated threads even if releasing their claimed jobs fails - #791

Merged
rosa merged 1 commit into
mainfrom
protect-thread-replacement
Aug 22, 2026
Merged

Replace terminated threads even if releasing their claimed jobs fails#791
rosa merged 1 commit into
mainfrom
protect-thread-replacement

Conversation

@rosa

@rosa rosa commented Aug 22, 2026

Copy link
Copy Markdown
Member

The async supervisor has the same hole #781 closed for forks: a worker thread that dies when the database is unreachable — likely the very reason it died — takes the whole supervise loop down with it when replace_thread tries to fail its claimed jobs before starting the replacement, leaving the supervisor permanently dead with a growing backlog, as in #683.

This hoists #781's rescued release into the Maintenance concern both supervisors share, with callers passing the error since forks and threads terminate with different ones, and uses it from replace_thread. As with forks, the terminated thread's claimed jobs aren't lost by skipping the release: its stale registration is pruned once the database is reachable again, and pruning fails its claimed executions through the normal path.

🤖 Generated with Claude Code

The async supervisor had the same hole #781 closed for forks: a worker
thread that dies when the database is unreachable — likely the very
reason it died — took the whole supervise loop down with it when
replace_thread tried to fail its claimed jobs before starting the
replacement. Hoist the rescued release into the Maintenance concern
both supervisors share, and let callers pass the error, since forks
and threads terminate with different ones.

As with forks, the terminated thread's claimed jobs aren't lost by
skipping the release: its stale registration is pruned once the
database is reachable again, and pruning fails its claimed executions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rosa
rosa merged commit d7d6c2b into main Aug 22, 2026
116 checks passed
@rosa
rosa deleted the protect-thread-replacement branch August 22, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant