Explicitly check for None
rather than False
#1240
Merged
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.
If the group leader somehow gets in a state that it has an empty partition assignment, then
self._assignment_snapshot
will be{}
which evaluates toFalse
. Soself._subscription.mark_for_reassignment()
will never be triggered, even ifself._assignment_snapshot != self._metadata_snapshot
.Here is the relevant upstream Java code:
https://github.com/apache/kafka/blob/c5d26c4829583c95af7ca9e961a4d3954f8e09eb/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java#L197
Fixes the symptoms of #1237 although I suspect there's an additional bug in that case that triggers the condition of the the group leader getting an empty partition assignment.
I'm hesitant with this fix because I still don't fully understand the race condition that results in the group leader simultaneously having:
3.
subscription.needs_partition_assignment = False
.Related: #1237 / #1241 / #1242