kirktrue commented on code in PR #17022: URL: https://github.com/apache/kafka/pull/17022#discussion_r2051328782
########## clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java: ########## @@ -737,14 +737,21 @@ public synchronized void maybeTransitionToErrorState(RuntimeException exception) } synchronized void handleFailedBatch(ProducerBatch batch, RuntimeException exception, boolean adjustSequenceNumbers) { - maybeTransitionToErrorState(exception); + if (!isStaleBatch(batch) && !hasFatalError()) Review Comment: Based on the type of the exception pass in, the logic in `maybeTransitionToErrorState()` may set the internal state to either `FATAL_ERROR` or `ABORTABLE_ERROR`. Assuming there's a race condition of failures, it's possible the transaction manager could be set to a `FATAL_ERROR` state, followed by a call to `handleFailedBatch()` that then attempts to set the state to `ABORTABLE_ERROR`. Transitioning from `FATAL_ERROR` to any other state results in an `IllegalStateException`. This is an attempt to prevent that case. I will add another unit test or two to make sure this is a valid concern. cc @jolshan -- 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