rreddy-22 commented on code in PR #23630:
URL: https://github.com/apache/kafka/pull/23630#discussion_r4149477187


##########
core/src/test/scala/unit/kafka/coordinator/transaction/TransactionStateManagerTest.scala:
##########
@@ -480,6 +518,23 @@ class TransactionStateManagerTest {
     transactionManager.appendTransactionToLog(transactionalId1, 
coordinatorEpoch = 10, failedMetadata, assertCallback,  requestLocal = 
RequestLocal.withThreadConfinedCaching)
   }
 
+  @Test
+  def testAppendSucceededButLeadershipLostBeforeCallback(): Unit = {
+    transactionManager.addLoadedTransactionsToCache(partitionId, 
coordinatorEpoch, new ConcurrentHashMap[String, TransactionMetadata]())
+    transactionManager.putTransactionStateIfNotExists(txnMetadata1)
+
+    // the write succeeds but the replica becomes a follower before the 
callback runs

Review Comment:
   It's the completion callback in appendTransactionToLog 
(updateCacheCallback), there's a change in behavior cause of our change. If the 
append succeeds but the replica becomes a follower before that callback runs, 
the callback's lookup now returns NOT_COORDINATOR instead of NONE. The record 
is already replicated, so the client's retry on the new coordinator is 
idempotent. No correctness issues or unexpected behavior



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