ableegoldman commented on a change in pull request #8445:
URL: https://github.com/apache/kafka/pull/8445#discussion_r414921746



##########
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:
       The reasoning being that we use `CommitFailedException` to signal we 
have dropped out of the group, and `RebalanceInProgressException` to signal 
that a rebalance is in progress. There are two cases to consider (within the 
general case of the generation having changed):
   1.  If the generation is unknown and the state is `STABLE` this means we 
have dropped out of the group, but haven't yet rejoined and haven't invoked 
`onPartitionsLost` --> should throw `CommitFailed`
   2. If the generation is unknown and the state is `REBALANCING` this means we 
dropped out of the group, but have already noticed and rejoined, and already 
invoked `onPartitionsLost` --> should throw `RebalanceInProgress`
   
   Note that if we dropped out of the group and already _completed_ the rejoin, 
the state will be `STABLE` again but the generation will also have been set so 
this case does not apply. Basically, we want to keep `CommitFailedException` to 
indicate that the consumer definitely dropped out and will have to rejoin, 
which is the case in 1. above




----------------------------------------------------------------
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


Reply via email to