Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Currently if a transactional producer hits a fatal exception, the caller usually catches the exception and handle it by aborting the transaction by invoking abortTransaction, and closing the the producer, which makes sense and sounds clean. The tricky scenario is that abortTransaction is not a safe call when the producer is already in an error state, which means user has to do another try-catch with the first layer catch block, making the error handling pretty annoying. It is more appropriate and user-friendly to ensure that the producer client does not throw the same exception again while aborting transaction.

Public Interfaces

org/apache/kafka/clients

Proposed Changes

Our proposal is quite straightforward and simple. To avoid throwing same exceptions twice, we can determine whether the producer client is already in error state in abortTransaction. If yes, the producer client does nothing. Otherwise it enforces the actual transaction aborting.

Public Interfaces

We Also, we shall modify the comments on abortTransaction and remove all exceptions except TimeoutException and InterruptException

...