Fix #446: don't crash livelock detector when consumer not yet started#702
Open
wbarnha wants to merge 1 commit into
Open
Fix #446: don't crash livelock detector when consumer not yet started#702wbarnha wants to merge 1 commit into
wbarnha wants to merge 1 commit into
Conversation
The commit-livelock detector task periodically calls verify_all_partitions_active(), which iterates self.assignment(). When the consumer thread has not finished starting (observed with alternative event loops such as eventlet), assignment() raises ConsumerNotStarted and the unhandled exception crashes the app. There is nothing to verify until the consumer thread is up, so catch ConsumerNotStarted and skip the cycle instead of propagating it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHPL4VFWQRQPpjR1gXSKyL
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #702 +/- ##
==========================================
+ Coverage 94.14% 94.15% +0.01%
==========================================
Files 104 104
Lines 11136 11140 +4
Branches 1201 1201
==========================================
+ Hits 10484 10489 +5
+ Misses 551 550 -1
Partials 101 101 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
The commit-livelock detector (
_commit_livelock_detector, a backgroundService.task) periodically callsverify_all_partitions_active(), which iteratesself.assignment(). If the consumer thread hasn't finished starting yet,assignment()→_ensure_consumer()raises:That unhandled exception crashes the app. It was reported with the eventlet event loop (
-L eventlet), where thread startup timing differs, but it's a general startup race in the detector.Fixes #446.
How
verify_all_partitions_active()now catchesConsumerNotStartedaround theassignment()call and returns early — there is simply nothing to verify until the consumer thread is up, so the detector skips that cycle and tries again on the next tick instead of propagating the exception.Test
Added
test_verify_all_partitions_active__consumer_not_startedintests/unit/transport/test_consumer.py: makesassignment()raiseConsumerNotStartedand assertsverify_all_partitions_active()returns without raising and without verifying any partition. Fulltests/unit/transport/test_consumer.pypasses (114 passed, 2 skipped).🤖 Generated with Claude Code
Generated by Claude Code