kirktrue commented on code in PR #13591: URL: https://github.com/apache/kafka/pull/13591#discussion_r1185533261
########## clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java: ########## @@ -1090,6 +1090,9 @@ private void maybeFailWithError() { } else if (lastError instanceof InvalidProducerEpochException) { throw new InvalidProducerEpochException("Producer with transactionalId '" + transactionalId + "' and " + producerIdAndEpoch + " attempted to produce with an old epoch"); + } else if (lastError instanceof IllegalStateException) { + throw new IllegalStateException("Producer with transactionalId '" + transactionalId Review Comment: Message now says: ``` Producer with transactionalId '<foo>' and <bar> cannot execute transactional method because of previous invalid state transition attempt ``` The `IllegalStateException` thrown from `maybeFailWithError` includes `lastError` as its `cause`. The stack trace would include the message for `lastError` which reads: ``` TransactionalId <foo>: Invalid transition attempted from state <current state> to state <target state> ``` Here's what it looks like from one of the unit tests: ``` Producer with transactionalId 'foobar' and ProducerIdAndEpoch(producerId=13131, epoch=1) cannot execute transactional method because of previous invalid state transition attempt java.lang.IllegalStateException: Producer with transactionalId 'foobar' and ProducerIdAndEpoch(producerId=13131, epoch=1) cannot execute transactional method because of previous invalid state transition attempt at org.apache.kafka.clients.producer.internals.TransactionManager.maybeFailWithError(TransactionManager.java:1112) at org.apache.kafka.clients.producer.internals.TransactionManager.beginTransaction(TransactionManager.java:324) at org.apache.kafka.clients.producer.internals.TransactionManagerTest.testBackgroundInvalidStateTransitionIsFatal(TransactionManagerTest.java:3422) . . . Caused by: java.lang.IllegalStateException: TransactionalId foobar: Invalid transition attempted from state READY to state ABORTABLE_ERROR at org.apache.kafka.clients.producer.internals.TransactionManager.transitionTo(TransactionManager.java:1070) at org.apache.kafka.clients.producer.internals.TransactionManager.transitionToAbortableError(TransactionManager.java:467) at org.apache.kafka.clients.producer.internals.TransactionManager.maybeTransitionToErrorState(TransactionManager.java:707) at org.apache.kafka.clients.producer.internals.TransactionManager.handleFailedBatch(TransactionManager.java:714) at org.apache.kafka.clients.producer.internals.TransactionManagerTest.lambda$testBackgroundInvalidStateTransitionIsFatal$139(TransactionManagerTest.java:3418) at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:53) at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:35) at org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3083) at org.apache.kafka.clients.producer.internals.TransactionManagerTest.testBackgroundInvalidStateTransitionIsFatal(TransactionManagerTest.java:3418) ... 84 more ``` Does that seem like sufficient context? -- 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