Keep heartbeat alive during graceful shutdown#1585
Conversation
A draining worker is still alive and processing its in-flight jobs, but _shutdown cancelled every side task (including the heartbeat) before waiting for those jobs to drain. The frozen heartbeat made the worker look dead to stalled-worker recovery, which could then reclaim jobs that were still being processed. Cancel the other side tasks immediately (a draining worker must not fetch new jobs, defer periodics or listen for notifications), but keep the heartbeat beating until in-flight jobs have drained or been aborted, and only then cancel it before unregistering the worker. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe worker's shutdown sequence is modified so the heartbeat task runs independently from other side tasks. ChangesHeartbeat lifecycle during graceful shutdown
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I opened issue #1598 for a closely related problem. It seems to me that the |
A draining worker is still alive and processing its in-flight jobs, but _shutdown cancelled every side task (including the heartbeat) before waiting for those jobs to drain. The frozen heartbeat made the worker look dead to stalled-worker recovery, which could then reclaim jobs that were still being processed.
Cancel the other side tasks immediately (a draining worker must not fetch new jobs, defer periodics or listen for notifications), but keep the heartbeat beating until in-flight jobs have drained or been aborted, and only then cancel it before unregistering the worker.
This is kind of fixable on library's users side with something like this but it looks like it would be worth it to address this in the library itself.
Successful PR Checklist:
PR label(s):
Summary by CodeRabbit
Bug Fixes
Tests