artemlivshits commented on code in PR #20039:
URL: https://github.com/apache/kafka/pull/20039#discussion_r2176173829


##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -1500,8 +1500,21 @@ public void handleResponse(AbstractResponse response) {
                 ProducerIdAndEpoch producerIdAndEpoch = new 
ProducerIdAndEpoch(initProducerIdResponse.data().producerId(),
                         initProducerIdResponse.data().producerEpoch());
                 setProducerIdAndEpoch(producerIdAndEpoch);
-                // TO_DO Add code to handle transition to prepared_txn when 
keepPrepared = true
-                transitionTo(State.READY);
+                // If this is a 2PC-enabled transaction with 
keepPreparedTxn=true, transition directly
+                // to PREPARED_TRANSACTION state IFF there is an ongoing 
transaction.
+                if (enable2PC &&

Review Comment:
   We allow using `keepPreparedTxn` even if `enable2PC == false`.



##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -1500,8 +1500,21 @@ public void handleResponse(AbstractResponse response) {
                 ProducerIdAndEpoch producerIdAndEpoch = new 
ProducerIdAndEpoch(initProducerIdResponse.data().producerId(),
                         initProducerIdResponse.data().producerEpoch());
                 setProducerIdAndEpoch(producerIdAndEpoch);
-                // TO_DO Add code to handle transition to prepared_txn when 
keepPrepared = true
-                transitionTo(State.READY);
+                // If this is a 2PC-enabled transaction with 
keepPreparedTxn=true, transition directly
+                // to PREPARED_TRANSACTION state IFF there is an ongoing 
transaction.
+                if (enable2PC &&
+                    builder.data.keepPreparedTxn() &&
+                    initProducerIdResponse.data().ongoingTxnProducerId() != -1

Review Comment:
   There is a `RecordBatch.NO_PRODUCER_ID` constant, we should use it.



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