chia7712 commented on a change in pull request #8657:
URL: https://github.com/apache/kafka/pull/8657#discussion_r483552275



##########
File path: 
core/src/test/scala/unit/kafka/coordinator/AbstractCoordinatorConcurrencyTest.scala
##########
@@ -201,8 +201,8 @@ object AbstractCoordinatorConcurrencyTest {
         }
       }
       val producerRequestKeys = 
entriesPerPartition.keys.map(TopicPartitionOperationKey(_)).toSeq
-      watchKeys ++= producerRequestKeys
       producePurgatory.tryCompleteElseWatch(delayedProduce, 
producerRequestKeys)
+      watchKeys ++= producerRequestKeys

Review comment:
       > Do you see the test fail due to a deadlock?
   
   the following read/write lock is from```stateLock``` of 
```TransactionStateManager```
   
   1. Thread_1: holding readlock and waiting for lock of delayed op 
(TransactionStateManager#appendTransactionToLog)
   2. Thread_2: waiting for writelock 
(```TransactionCoordinatorConcurrencyTest#testConcurrentGoodPathWithConcurrentPartitionLoading```)
       ```
       val t = new Thread() {
         override def run(): Unit = {
           while (keepRunning.get()) {
             txnStateManager.addLoadingPartition(numPartitions + 1, 
coordinatorEpoch)
           }
         }
       }
       private[transaction] def addLoadingPartition(partitionId: Int, 
coordinatorEpoch: Int): Unit = {
         val partitionAndLeaderEpoch = 
TransactionPartitionAndLeaderEpoch(partitionId, coordinatorEpoch)
         inWriteLock(stateLock) {
           loadingPartitions.add(partitionAndLeaderEpoch)
         }
       }
       ```
   3. Thread_3: holding lock of delayed op and waiting for readlock (another 
thread is trying to complete delayed op)
   
   **deadlock**
   1. Thread_1 is waiting for thread_3
   1. Thread_3 is waiting for Thread_2
   1. Thread_2 is waiting for thread_1




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to