showuon commented on a change in pull request #10863: URL: https://github.com/apache/kafka/pull/10863#discussion_r650895147
########## 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: SGTM. Thanks. -- 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