You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "k-raina (via GitHub)" <gi...@apache.org> on 2025/05/07 14:05:57 UTC
[PR] txnProducer.abortTransaction() API should not return abortable exception [kafka]
k-raina opened a new pull request, #19656:
URL: https://github.com/apache/kafka/pull/19656
## Problem
When an `txnProducer.abortTransaction()`operation encounters a `TRANSACTION_ABORTABLE` error, it currently tries to transition to `ABORTABLE_ERROR` state. This can create an infinite retry loop since:
1. The abort operation fails with `TRANSACTION_ABORTABLE`
2. We transition to `ABORTABLE_ERROR` state
3. The application recieves instance of TransactionAbortableException and it retries the abort
4. The cycle repeats
## Solution
For `txnProducer.abortTransaction()`API, convert `TRANSACTION_ABORTABLE` errors to fatal errors (`KafkaException`) during abort operations to ensure clean transaction termination. This prevents retry loops by:
1. Treating abort failures as fatal errors at application layer
2. Ensuring the transaction can be cleanly terminated
3. Providing clear error messages to the application
## Changes
- Modified `EndTxnHandler.handleResponse()` to convert `TRANSACTION_ABORTABLE` errors to `KafkaException` during abort operations
- Set TransactionManager state to FATAL
- Updated test `testAbortableErrorIsConvertedToFatalErrorDuringAbort` to verify this behavior
## Testing
- Added test case verifying that abort operations convert `TRANSACTION_ABORTABLE` errors to `KafkaException`
- Verified that Commit API with TRANSACTION_ABORTABLE error should set TM to Abortable state
- Verified that Abort API with TRANSACTION_ABORTABLE error should convert to Fatal error i.e. KafkaException
## Impact
At application layer, this change improves transaction reliability by preventing infinite retry loops during abort operations.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19250 : txnProducer.abortTransaction() API should not return abortable exception [kafka]
Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan merged PR #19656:
URL: https://github.com/apache/kafka/pull/19656
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] txnProducer.abortTransaction() API should not return abortable exception [kafka]
Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #19656:
URL: https://github.com/apache/kafka/pull/19656#discussion_r2082645597
##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -1674,7 +1675,7 @@ boolean isEndTxn() {
public void handleResponse(AbstractResponse response) {
EndTxnResponse endTxnResponse = (EndTxnResponse) response;
Errors error = endTxnResponse.error();
-
+ boolean isAbortApi = !builder.data.committed();
Review Comment:
nit: maybe we can just call this `isAbort` or even have the conditional inline.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19250 : txnProducer.abortTransaction() API should not return abortable exception [kafka]
Posted by "k-raina (via GitHub)" <gi...@apache.org>.
k-raina commented on PR #19656:
URL: https://github.com/apache/kafka/pull/19656#issuecomment-2934966301
Unrelated test failures as similiar failures are in another PR Job
https://github.com/apache/kafka/actions/runs/15096607388/job/42432258294
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org