Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ public void handle(HeartbeatResponse heartbeatResponse, RequestFuture<Void> futu
log.info("Attempt to heart beat failed since coordinator is either not started or not valid, marking it as dead.");
coordinatorDead();
future.raise(Errors.forCode(error));
} else if (error == Errors.REBALANCE_IN_PROGRESS.code()) {
log.info("Attempt to heart beat failed since the group is rebalancing, try to re-join group.");
subscriptions.needReassignment();
future.raise(Errors.REBALANCE_IN_PROGRESS);
} else if (error == Errors.ILLEGAL_GENERATION.code()) {
log.info("Attempt to heart beat failed since generation id is not legal, try to re-join group.");
subscriptions.needReassignment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public enum Errors {
new ApiException("Some of the committing partitions are not assigned the committer")),
INVALID_COMMIT_OFFSET_SIZE(28,
new ApiException("The committing offset data size is not valid")),
AUTHORIZATION_FAILED(29, new ApiException("Request is not authorized."));
AUTHORIZATION_FAILED(29, new ApiException("Request is not authorized.")),
REBALANCE_IN_PROGRESS(30,
new ApiException("The group is rebalancing, so a rejoin is needed."));

private static final Logger log = LoggerFactory.getLogger(Errors.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ class ConsumerCoordinator(val brokerId: Int,
responseCallback(Errors.UNKNOWN_CONSUMER_ID.code)
} else if (!group.has(consumerId)) {
responseCallback(Errors.UNKNOWN_CONSUMER_ID.code)
} else if (generationId != group.generationId || !group.is(Stable)) {
} else if (generationId != group.generationId) {
responseCallback(Errors.ILLEGAL_GENERATION.code)
} else if (!group.is(Stable)) {
responseCallback(Errors.REBALANCE_IN_PROGRESS.code)
} else {
val consumer = group.get(consumerId)
completeAndScheduleNextHeartbeatExpiration(group, consumer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class ConsumerCoordinatorResponseTest extends JUnitSuite {
}

@Test
def testHeartbeatDuringRebalanceCausesIllegalGeneration() {
def testHeartbeatDuringRebalanceCausesRebalanceInProgress() {
val groupId = "groupId"
val partitionAssignmentStrategy = "range"

Expand All @@ -249,10 +249,10 @@ class ConsumerCoordinatorResponseTest extends JUnitSuite {
sendJoinGroup(groupId, JoinGroupRequest.UNKNOWN_CONSUMER_ID, partitionAssignmentStrategy,
DefaultSessionTimeout, isCoordinatorForGroup = true)

// We should be in the middle of a rebalance, so the heartbeat should return illegal generation
// We should be in the middle of a rebalance, so the heartbeat should return rebalance in progress
EasyMock.reset(offsetManager)
val heartbeatResult = heartbeat(groupId, assignedConsumerId, initialGenerationId, isCoordinatorForGroup = true)
assertEquals(Errors.ILLEGAL_GENERATION.code, heartbeatResult)
assertEquals(Errors.REBALANCE_IN_PROGRESS.code, heartbeatResult)
}

@Test
Expand Down