chia7712 commented on a change in pull request #8657: URL: https://github.com/apache/kafka/pull/8657#discussion_r484163863
########## File path: core/src/main/scala/kafka/server/DelayedOperation.scala ########## @@ -231,26 +214,27 @@ final class DelayedOperationPurgatory[T <: DelayedOperation](purgatoryName: Stri // At this point the only thread that can attempt this operation is this current thread // Hence it is safe to tryComplete() without a lock - var isCompletedByMe = operation.tryComplete() - if (isCompletedByMe) - return true - - var watchCreated = false - for(key <- watchKeys) { - // If the operation is already completed, stop adding it to the rest of the watcher list. - if (operation.isCompleted) - return false - watchForOperation(key, operation) - - if (!watchCreated) { - watchCreated = true - estimatedTotalOperations.incrementAndGet() + if (operation.tryComplete()) return true Review comment: As the potential deadlock caused by holding lock in ```tryCompleteElseWatch```, I DON"T change the ```tryComplete``` to ```safeTryComplete```. Maybe we can deal with this issue when we meet such issue. ---------------------------------------------------------------- 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