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


##########
core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:
##########
@@ -524,15 +754,16 @@ class TransactionCoordinator(txnConfig: TransactionConfig,
             producerIdCopy = txnMetadata.producerId
             producerEpochCopy = txnMetadata.producerEpoch
             // PrepareEpochFence has slightly different epoch bumping logic so 
don't include it here.
-            val currentTxnMetadataIsAtLeastTransactionsV2 = 
!txnMetadata.pendingState.contains(PrepareEpochFence) && 
txnMetadata.clientTransactionVersion.supportsEpochBump()
+            // Note that, it can only happen when the current state is Ongoing.
+            isEpochFence = txnMetadata.pendingState.contains(PrepareEpochFence)
             // True if the client used TV_2 and retried a request that had 
overflowed the epoch, and a new producer ID is stored in the txnMetadata
-            val retryOnOverflow = currentTxnMetadataIsAtLeastTransactionsV2 &&
-              txnMetadata.previousProducerId == producerId && producerEpoch == 
Short.MaxValue - 1 && txnMetadata.producerEpoch == 0
+            val retryOnOverflow = !isEpochFence && 
txnMetadata.previousProducerId == producerId &&
+              producerEpoch == Short.MaxValue - 1 && txnMetadata.producerEpoch 
== 0
             // True if the client used TV_2 and retried an endTxn request, and 
the bumped producer epoch is stored in the txnMetadata.
-            val retryOnEpochBump = endTxnEpochBumped(txnMetadata, 
producerEpoch)
+            val retryOnEpochBump = 
!txnMetadata.pendingState.contains(PrepareEpochFence) && 
txnMetadata.producerEpoch == producerEpoch + 1

Review Comment:
   Can we use `isEpocFence` here as well?  The condition above looks logically 
similar, but for some reason we use different sub-conditions.  Also looks like 
the comments don't correspond to the code anymore.



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