jolshan commented on code in PR #19429:
URL: https://github.com/apache/kafka/pull/19429#discussion_r2051125842


##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -654,6 +657,46 @@ public void initTransactions() {
         transactionManager.maybeUpdateTransactionV2Enabled(true);
     }
 
+    /**
+     * Initialize the transactional state for this producer, similar to {@link 
#initTransactions()} but
+     * with additional handling for two-phase commit (2PC). Must be called 
before any send operations
+     * that require a {@code transactionalId}.
+     * <p>
+     * Unlike the standard {@link #initTransactions()}, when {@code 
keepPreparedTxn} is set to
+     * {@code true}, the producer does <em>not</em> automatically abort 
existing transactions
+     * in the “prepare” phase. Instead, it enters a recovery mode allowing 
only finalization
+     * of those previously prepared transactions. This behavior is crucial for 
2PC scenarios,

Review Comment:
   I think the phrasing here is sufficient without the method specification. 
   
   >  in the “prepare” phase
   
   I think maybe we shouldn't use this phrasing since it is a little confusing. 
The transactions are in the prepare phase for external 2PC but from the Kafka 
point of view, they are in the ongoing phase. 
   
   Artem may have opinions here too, so happy to hear his thoughts and if he 
disagrees. 



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