Skip to content

Fix #446: don't crash livelock detector when consumer not yet started#702

Open
wbarnha wants to merge 1 commit into
masterfrom
claude/fix-446-livelock-consumer-not-started
Open

Fix #446: don't crash livelock detector when consumer not yet started#702
wbarnha wants to merge 1 commit into
masterfrom
claude/fix-446-livelock-consumer-not-started

Conversation

@wbarnha

@wbarnha wbarnha commented Jul 19, 2026

Copy link
Copy Markdown
Member

What

The commit-livelock detector (_commit_livelock_detector, a background Service.task) periodically calls verify_all_partitions_active(), which iterates self.assignment(). If the consumer thread hasn't finished starting yet, assignment()_ensure_consumer() raises:

faust.exceptions.ConsumerNotStarted: Consumer thread not yet started

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 catches ConsumerNotStarted around the assignment() 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_started in tests/unit/transport/test_consumer.py: makes assignment() raise ConsumerNotStarted and asserts verify_all_partitions_active() returns without raising and without verifying any partition. Full tests/unit/transport/test_consumer.py passes (114 passed, 2 skipped).

🤖 Generated with Claude Code


Generated by Claude Code

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

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.15%. Comparing base (3073eb9) to head (2b9c16a).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

faust.exceptions.ConsumerNotStarted: Consumer thread not yet started

1 participant