Explicitly use OFFSET_STORED in assign(), add tests for offset resume#33
Merged
Explicitly use OFFSET_STORED in assign(), add tests for offset resume#33
Conversation
Makes the committed-offset resume behavior explicit rather than relying on librdkafka's implicit default. Critical invariant: replica count changes must resume from committed offsets, not replay from earliest.
There was a problem hiding this comment.
Pull request overview
This PR makes the consumer’s committed-offset resume behavior explicit by passing OFFSET_STORED in Consumer.assign(), and adds unit tests to ensure the assignment uses stored offsets and that auto.offset.reset is configured as earliest.
Changes:
- Explicitly assign partitions with
OFFSET_STOREDto resume from committed offsets. - Add unit test verifying every assigned
TopicPartitionusesOFFSET_STORED. - Add unit test asserting
auto.offset.resetis set toearliest(fallback behavior for never-committed partitions).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
millpond/consumer.py |
Passes OFFSET_STORED explicitly in consumer.assign() and documents the rationale. |
tests/unit/test_consumer.py |
Adds unit tests covering OFFSET_STORED usage in assignments and auto.offset.reset configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Makes the committed-offset resume behavior explicit in
consumer.assign(). Previously relied on librdkafka's implicit default (OFFSET_INVALID→ same asOFFSET_STORED). Now explicitly passesOFFSET_STOREDso the intent is clear in code.Why this matters: When replica count changes (e.g. 4 → 2 pods), partitions get reassigned to different pods. Each pod must resume from the offset committed by whichever pod previously owned that partition — not replay from earliest.
OFFSET_STOREDfetches the committed offset from__consumer_offsets, falling back toauto.offset.reset=earliestonly if no offset has ever been committed.No functional change — just making the invariant explicit and tested.
Test plan
test_assign_uses_stored_offsets— verifies every partition usesOFFSET_STOREDtest_auto_offset_reset_is_earliest— verifies fallback for new partitions