Repository navigation
Fix StickyPartitionAssignor invalid previous_assignment reassignments and generation 0 conflict check - #3209
Open
utku0dogan wants to merge 1 commit into
Open
utku0dogan wants to merge 1 commit into
utku0dogan wants to merge 1 commit into
Conversation
… 0 conflict handling
Contributor
Author
|
@dpkp py 3.14 / kafka 3.9.0 / net random: test_sasl_integration.py failed during fixture setup (RuntimeError: Failed to create Zookeeper chroot node). Could someone re-run the failed jobs when convenient? |
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
Fixes three related bugs in
StickyAssignmentExecutor(kafka/coordinator/assignors/sticky/sticky_assignor.py):_perform_reassignments):When moving a partition back to
self.previous_assignment[partition].consumer, the assignor did not verify thatprev_consumeris still subscribed topartition.topic(prev_consumer in self.partition_to_all_potential_consumers[partition]). During rebalances with mixed/changing subscriptions and conflicting generations, a member could be assigned a partition for a topic it is not subscribed to.KeyErrorwhenprev_consumerwas moved tofixed_assignments(_perform_reassignments):balance()removes fixed consumers fromself.current_assignment, which is adefaultdict(list). Indexingself.current_assignment[prev_consumer]without checkingprev_consumer in self.current_assignmentauto-vivified an empty list (len == 0) and caused_move_partitionto crash withKeyErrorinsorted_current_subscriptions.remove(...).generation == 0falsy check (_init_current_assignments):if member_metadata.generation and member_metadata.generation in consumers:treated valid generation0as falsy, silently overwriting the earlier owner instead of logging a warning and preserving it like generations>= 1.Tests
Added three regression tests in
test/consumer/test_assignors.py:test_reassignment_does_not_assign_unsubscribed_topic_from_previous_assignmenttest_reassignment_skips_fixed_previous_consumertest_conflicting_generation_zero_preserves_first_ownerVerified with
pytest test/consumer/test_assignors.py(187 passed).