dajac commented on a change in pull request #10863: URL: https://github.com/apache/kafka/pull/10863#discussion_r650806015
########## File path: core/src/main/scala/kafka/coordinator/group/GroupCoordinator.scala ########## @@ -1450,12 +1463,67 @@ class GroupCoordinator(val brokerId: Int, group.maybeInvokeJoinCallback(member, joinResult) completeAndScheduleNextHeartbeatExpiration(group, member) member.isNew = false + + group.addPendingSyncMember(member.memberId) } + + val delayedSync = new DelayedSync(this, group, group.rebalanceTimeoutMs) + val groupKey = GroupKey(group.groupId) + syncPurgatory.tryCompleteElseWatch(delayedSync, Seq(groupKey)) } } } } + private def maybeCompleteSyncExpiration( + group: GroupMetadata + ): Unit = { + val groupKey = GroupKey(group.groupId) + syncPurgatory.checkAndComplete(groupKey) + } + + def tryCompletePendingSync( + group: GroupMetadata, + forceComplete: () => Boolean + ): Boolean = { + group.inLock { + group.currentState match { + case Dead | Empty | PreparingRebalance => + forceComplete() + case CompletingRebalance | Stable => + if (group.hasReceivedSyncFromAllMembers()) + forceComplete() + else false + } + } + } + + def onExpirePendingSync( + group: GroupMetadata + ): Unit = { + group.inLock { + group.currentState match { + case Dead | Empty | PreparingRebalance => + debug(s"Received notification of sync expiration for group ${group.groupId} in ${group.currentState} state. Ignoring.") Review comment: I am not really convinced by this. My intent was to have a comment for the unexpected cases. I prefer to keep it as it is. ########## File path: core/src/main/scala/kafka/coordinator/group/GroupCoordinator.scala ########## @@ -1209,7 +1216,11 @@ class GroupCoordinator(val brokerId: Int, } private def removeHeartbeatForLeavingMember(group: GroupMetadata, member: MemberMetadata): Unit = { - val memberKey = MemberKey(group.groupId, member.memberId) Review comment: Make sense. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org