You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Status

Current state: Under Discussion

Discussion thread:

JIRA: KAFKA-9592

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Currently if a transactional producer hits a fatal exception, the caller usually catches the exception and handle it by aborting the transaction by invoking abortTxn, and closing the the producer, which makes sense and sounds clean. The tricky scenario is that abortTxn 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 abortTxn. If yes, the producer client does nothing. Otherwise it enforces the actual transaction aborting.

Compatibility, Deprecation, and Migration Plan

Our proposed change can be considered as minor. In users' perspective, they have less exceptions to worry and handle when calling abortTxn. 

Rejected Alternatives

  1. Internally abort any ongoing transaction within `producer.close`, and comment on `abortTxn` call to warn user not to do it manually. 
  2. Similar to 1, but get a new `close(boolean abortTxn)` API call in case some users want to handle transaction state by themselves.
  3. Introduce a new abort transaction API with a boolean flag indicating whether the producer is in error state, instead of throwing exceptions
  4. Introduce a public API `isInError` on producer for user to validate before doing any transactional API calls

The alternatives are rejected because they all require a bigger change.


  • No labels