CalvinConfluent commented on code in PR #17822:
URL: https://github.com/apache/kafka/pull/17822#discussion_r1844298440


##########
core/src/test/scala/integration/kafka/api/TransactionsTest.scala:
##########
@@ -763,7 +763,10 @@ class TransactionsTest extends IntegrationTestHarness {
   }
 
   @ParameterizedTest(name = 
TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)

Review Comment:
   TestWithParameterizedQuorumAndGroupProtocolNames does not support disabling 
TV2, I wonder if we want to remove the "true" in the csv list.



##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -339,27 +338,24 @@ private TransactionalRequestResult 
beginCompletingTransaction(TransactionResult
         if (!newPartitionsInTransaction.isEmpty())
             enqueueRequest(addPartitionsToTransactionHandler());
 
-        // If the error is an INVALID_PRODUCER_ID_MAPPING error, the server 
will not accept an EndTxnRequest, so skip
-        // directly to InitProducerId. Otherwise, we must first abort the 
transaction, because the producer will be
-        // fenced if we directly call InitProducerId.
-        if (!(lastError instanceof InvalidPidMappingException)) {
-            EndTxnRequest.Builder builder = new EndTxnRequest.Builder(
-                    new EndTxnRequestData()
-                            .setTransactionalId(transactionalId)
-                            .setProducerId(producerIdAndEpoch.producerId)
-                            .setProducerEpoch(producerIdAndEpoch.epoch)
-                            .setCommitted(transactionResult.id),
-                    isTransactionV2Enabled
-            );
+        EndTxnRequest.Builder builder = new EndTxnRequest.Builder(
+            new EndTxnRequestData()
+                .setTransactionalId(transactionalId)
+                .setProducerId(producerIdAndEpoch.producerId)
+                .setProducerEpoch(producerIdAndEpoch.epoch)
+                .setCommitted(transactionResult.id),
+            isTransactionV2Enabled
+        );
 
-            EndTxnHandler handler = new EndTxnHandler(builder);
-            enqueueRequest(handler);
-            if (!epochBumpRequired) {
-                return handler.result;
-            }
+        EndTxnHandler handler = new EndTxnHandler(builder);
+        enqueueRequest(handler);
+
+        // If an epoch bump is required for recovery, initialize the 
transaction after completing the EndTxn request.
+        if (epochBumpRequired) {

Review Comment:
   Just to double check. The long-term goal is to only call initProducerId 
request when initializing the producer and we will not call it again when the 
producer is running. I guess it will be a separate change?



-- 
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

Reply via email to