kirktrue commented on code in PR #17022:
URL: https://github.com/apache/kafka/pull/17022#discussion_r2138442177


##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -779,14 +779,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;

Review Comment:
   @jolshan—There are a number of tests that fail with the latest change:
   
   * `TransactionManagerTest.testTransitionToAbortableErrorOnBatchExpiry()`
   * 
`TransactionManagerTest.testTransitionToAbortableErrorOnMultipleBatchExpiry()`
   * `TransactionManagerTest.testBackgroundInvalidStateTransitionIsFatal()`
   * `TransactionsTest.testBumpTransactionalEpochWithTV2Disabled()`
   * 
`TransactionsWithTieredStoreTest.testBumpTransactionalEpochWithTV2Disabled()`
   
   From the perspective of those tests, the state should be set to 
`FATAL_ERROR` in the case where the batch’s producer ID is different from the 
transaction manager’s.



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

Reply via email to