Fix committed-offset bookkeeping advancing when commit fails#692
Open
wbarnha wants to merge 1 commit into
Open
Fix committed-offset bookkeeping advancing when commit fails#692wbarnha wants to merge 1 commit into
wbarnha wants to merge 1 commit into
Conversation
Consumer._commit_offsets updated self._committed_offset and fired monitor.on_tp_commit() unconditionally, outside the `if did_commit:` guard. On any transient commit failure (e.g. UnknownMemberIdError during a rebalance), Faust's internal view of "what's committed" silently advanced anyway, risking offset loss under the default at-least-once guarantee: a later _should_commit() check would see those offsets as already committed and skip retrying them. Move both calls inside the `if did_commit:` block so bookkeeping only advances when the commit actually succeeded. Fixes #316. 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 #692 +/- ##
=======================================
Coverage 94.14% 94.15%
=======================================
Files 104 104
Lines 11136 11136
Branches 1201 1201
=======================================
+ Hits 10484 10485 +1
+ Misses 551 550 -1
Partials 101 101 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wbarnha
added a commit
that referenced
this pull request
Jul 19, 2026
Per review, the v0.12.0 changelog/release notes should describe only what is already on master, not work still in open PRs. - Remove the not-yet-merged items: the offset-commit data-loss fixes (#606/#707, #316/#692), the optional OpenTracing/OpenTelemetry extras (#685/#686, #688/#681), web_application_options (#704), and the reported-issue fix stack (#693-#703, #705). These will be added back as they merge. - Add a Dependencies section noting the current runtime/client libraries: mode-streaming >= 0.4.0, aiokafka >= 0.10.0 (compatible with recent 0.13/0.14 releases), the new confluent-kafka >= 2.0.0 for faust[ckafka], and the faust-cchardet fork replacing unmaintained cchardet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHPL4VFWQRQPpjR1gXSKyL
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.
Note: Before submitting this pull request, please review our contributing guidelines.
Description
Fixes #316.
Consumer._commit_offsets(faust/transport/consumer.py) updatedself._committed_offsetand firedself.app.monitor.on_tp_commit(...)unconditionally, outside theif did_commit:guard that already existed for thetables.on_commit(...)call two lines above.On any transient commit failure (e.g.
UnknownMemberIdErrorduring a rebalance — the scenario in the original report), Faust's internal bookkeeping silently advanced to record those offsets as committed even though the underlying Kafka commit never happened. A later_should_commit()check (committed = self._committed_offset[tp]; return committed is None or offset > committed) would then see those offsets as already committed and skip retrying them — risking real offset loss under the default at-least-once guarantee.Fix
Move
self._committed_offset.update(...)andself.app.monitor.on_tp_commit(...)inside the existingif did_commit:block, so bookkeeping only advances when the commit actually succeeded.Tests
test_commit_offsets__did_not_committo assertmonitor.on_tp_commitis not called and_committed_offsetis unchanged when the commit fails (did_commit=False).test_commit_offsets(happy path) to assertmonitor.on_tp_commitis called and_committed_offsetis updated when the commit succeeds, so both branches of the guard are covered.AssertionError: Expected 'on_tp_commit' to not have been called. Called 1 times.— confirming the test is not vacuous.flake8,black --check,isort --check-onlyclean on both changed files.🤖 Generated with Claude Code
Generated by Claude Code