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


##########
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionMetadata.java:
##########
@@ -257,8 +342,15 @@ public TxnTransitMetadata 
prepareAbortOrCommit(TransactionState newState,
         // start time is uncertain but it is still required. So we can use the 
update time as the transaction start time.
         data.txnStartTimestamp = noPartitionAdded ? updateTimestamp : 
txnStartTimestamp;
         data.nextProducerId = nextProducerId;
+        data.nextProducerEpoch = nextProducerEpoch;
         data.txnLastUpdateTimestamp = updateTimestamp;
         data.clientTransactionVersion = clientTransactionVersion;
+        // If the transaction was kept with 
InitProducerId(keepPreparedTxn=true), the client used the client-facing
+        // producer id, which may be different from the frozen producerId.  
Keep track of it as the previous
+        // producer id, so that the client's retry can be recognized if the 
producer id is rotated on completion.
+        if (hasNextProducerEpoch())
+            data.prevProducerId = clientProducerId();

Review Comment:
   I guess this change in what prevProducerId means for PREPARE_* states is 
made much easier by the reordering of the concurrent transactions check. 
Otherwise, this could have been a lot more complicated.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to