guozhangwang commented on a change in pull request #8445: URL: https://github.com/apache/kafka/pull/8445#discussion_r414912275
########## File path: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java ########## @@ -1209,9 +1227,18 @@ public void handle(OffsetCommitResponse commitResponse, RequestFuture<Void> futu return; } else if (error == Errors.UNKNOWN_MEMBER_ID || error == Errors.ILLEGAL_GENERATION) { - // need to reset generation and re-join group - resetGenerationOnResponseError(ApiKeys.OFFSET_COMMIT, error); - future.raise(new CommitFailedException()); + log.info("OffsetCommit failed with {}: {}", sentGeneration, error.message()); + + // only need to reset generation and re-join group if generation has not changed; + // otherwise only raise rebalance-in-progress error + if (generationUnchanged()) { + resetGenerationOnResponseError(ApiKeys.OFFSET_COMMIT, error); + future.raise(new CommitFailedException()); + } else { + future.raise(new RebalanceInProgressException("Offset commit cannot be completed since the " + Review comment: If the generation has changed since the commit request is sent, then it is likely that it has participated in a new rebalance (and hence get a new generation), or it has reset its generation due to the heartbeat failure. So this commit failure is recoverable. ---------------------------------------------------------------- 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