varunv-cflt opened a new pull request, #23174:
URL: https://github.com/apache/kafka/pull/23174

   ## Summary
   
   Two independent instances of the same bug class in classic consumer-group 
handling, found while investigating a Kafka Streams soak test that showed the 
same member joining consecutive generations in rapid succession, with an 
old-generation request timing out much later (after the client's rebalance 
timeout).
   
   ### 1. JoinGroup 
(`GroupMetadataManager#updateMemberThenRebalanceOrCompleteJoin`)
   `ClassicGroup#updateMember` silently overwrites a member's 
`awaitingJoinFuture` when the same member sends another `JoinGroup` while the 
group is still `PREPARING_REBALANCE` and its previous request hasn't completed. 
The discarded future is never completed by anything — it only resolves via the 
*original caller's own external deadline*, which surfaces as a timeout for a 
stale generation long after the member has already rejoined successfully under 
a newer generation. Fixed by completing the stale future with a retriable 
`REBALANCE_IN_PROGRESS` before it's replaced.
   
   ### 2. SyncGroup (`GroupMetadataManager#classicGroupSyncToClassicGroup`)
   Same bug shape, found independently while checking whether the JoinGroup fix 
also covered SyncGroup — it didn't. `classicGroupSyncToClassicGroup` sets 
`member.awaitingSyncFuture` directly with no check for an already-incomplete 
previous future. If a member sends a second `SyncGroup` for the same generation 
while the group is still `COMPLETING_REBALANCE` (e.g. still waiting on the 
leader's assignment), the first future is orphaned the same way. Fixed the same 
way: complete the stale future with `REBALANCE_IN_PROGRESS` before replacing it.
   
   Jira: https://issues.apache.org/jira/browse/KAFKA-20938
   
   ## Test plan
   - [x] 
`testJoinGroupExistingMemberRejoinDuringPreparingRebalanceCompletesPreviousJoinFuture`
 — reproduces a member rejoining (same memberId) while its first `JoinGroup` is 
still pending, asserts the first future now completes promptly with 
`REBALANCE_IN_PROGRESS`.
   - [x] 
`testSyncGroupDuplicateFollowerSyncDuringCompletingRebalanceCompletesPreviousSyncFuture`
 — same shape for `SyncGroup`.
   - [x] `./gradlew :group-coordinator:test --tests 
"org.apache.kafka.coordinator.group.GroupMetadataManagerTest"` — 495/495 tests 
pass, including existing static-member tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to