k-raina commented on code in PR #17022: URL: https://github.com/apache/kafka/pull/17022#discussion_r2054686862
########## clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java: ########## @@ -737,14 +737,25 @@ public synchronized void maybeTransitionToErrorState(RuntimeException exception) } synchronized void handleFailedBatch(ProducerBatch batch, RuntimeException exception, boolean adjustSequenceNumbers) { - maybeTransitionToErrorState(exception); + // Compare the batch with the current ProducerIdAndEpoch. If the producer IDs are the *same* but the epochs + // are *different*, consider the batch as stale. + boolean isStaleBatch = batch.producerId() == producerIdAndEpoch.producerId && batch.producerEpoch() != producerIdAndEpoch.epoch; + + if (!isStaleBatch && !hasFatalError()) + maybeTransitionToErrorState(exception); Review Comment: ``` // Therefore, only attempt to transition to the FATAL_ERROR state if // the batch is "fresh" *and* the transaction manager is not already // in the FATAL_ERROR state. ``` FATAL_ERROR to FATAL_ERROR[ is not an invalid transition](https://github.com/k-raina/kafka/blob/ab2cae14b93c13e21eda1d142d582bb7f42d7aec/clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java#L211-L233). Do you mean `only attempt transition to the ABORTABLE_ERROR state` EDIT: Okay i got that check is trying to say "Do not allow any transitions if we are in fatal state" -- 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. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org