Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions core/src/main/scala/kafka/coordinator/group/MemberMetadata.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ private[group] class MemberMetadata(var memberId: String,
}

def shouldKeepAlive(deadlineMs: Long): Boolean = {
if (isAwaitingJoin)
!isNew || latestHeartbeat + GroupCoordinator.NewMemberJoinTimeoutMs > deadlineMs
else awaitingSyncCallback != null ||

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced awaitingSyncCallback != null with isAwaitingSync

if (isNew) {
// New members are expired after the static join timeout
latestHeartbeat + GroupCoordinator.NewMemberJoinTimeoutMs > deadlineMs
} else if (isAwaitingJoin || isAwaitingSync) {
// Don't remove members as long as they have a request in purgatory
true
} else {
// Otherwise check for session expiration
latestHeartbeat + sessionTimeoutMs > deadlineMs
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,36 @@ class GroupCoordinatorTest {
assertEquals(Errors.INCONSISTENT_GROUP_PROTOCOL, joinGroupResult.error)
}

@Test
def testNewMemberTimeoutCompletion(): Unit = {
val sessionTimeout = GroupCoordinator.NewMemberJoinTimeoutMs + 5000
val responseFuture = sendJoinGroup(groupId, JoinGroupRequest.UNKNOWN_MEMBER_ID, protocolType, protocols, None, sessionTimeout, DefaultRebalanceTimeout, false)

timer.advanceClock(GroupInitialRebalanceDelay + 1)

val joinResult = Await.result(responseFuture, Duration(DefaultRebalanceTimeout + 100, TimeUnit.MILLISECONDS))
val group = groupCoordinator.groupManager.getGroup(groupId).get
val memberId = joinResult.memberId

assertEquals(Errors.NONE, joinResult.error)
assertEquals(0, group.allMemberMetadata.count(_.isNew))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth asserting latestHeartbeat as well?


EasyMock.reset(replicaManager)
val syncGroupResult = syncGroupLeader(groupId, joinResult.generationId, memberId, Map(memberId -> Array[Byte]()))
val syncGroupError = syncGroupResult._2

assertEquals(Errors.NONE, syncGroupError)
assertEquals(1, group.size)

timer.advanceClock(GroupCoordinator.NewMemberJoinTimeoutMs + 100)

// Make sure the NewMemberTimeout is not still in effect, and the member is not kicked
assertEquals(1, group.size)

timer.advanceClock(sessionTimeout + 100)
assertEquals(0, group.size)
}

@Test
def testNewMemberJoinExpiration(): Unit = {
// This tests new member expiration during a protracted rebalance. We first create a
Expand Down Expand Up @@ -1882,7 +1912,7 @@ class GroupCoordinatorTest {

val nextGenerationId = joinResult.generationId

// with no leader SyncGroup, the follower's request should failure with an error indicating
// with no leader SyncGroup, the follower's request should fail with an error indicating
// that it should rejoin
EasyMock.reset(replicaManager)
val followerSyncFuture = sendSyncGroupFollower(groupId, nextGenerationId, otherJoinResult.memberId, None)
Expand Down