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


##########
core/src/main/scala/kafka/log/UnifiedLog.scala:
##########
@@ -600,6 +600,11 @@ class UnifiedLog(@volatile var logStartOffset: Long,
    */
   def hasOngoingTransaction(producerId: Long, producerEpoch: Short): Boolean = 
lock synchronized {
     val entry = producerStateManager.activeProducers.get(producerId)
+    // With transactions V2, if we see a future epoch, we are likely in the 
process of completing the previous transaction.
+    // Return early with ConcurrentTransactionsException until the transaction 
completes.
+    if (entry != null && entry.currentTxnFirstOffset.isPresent && 
entry.producerEpoch() < producerEpoch)

Review Comment:
   It reminds me of an optimation 
https://issues.apache.org/jira/browse/KAFKA-18042
   Basically `entry.producerEpoch() > producerEpoch` is also illegal and can be 
rejected earlier instead of sending the add partition verification. I wonder if 
we can also throw an exception(ProducerFenced) here?



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