yufeiyan1220 commented on a change in pull request #11953:
URL: https://github.com/apache/kafka/pull/11953#discussion_r839195366



##########
File path: core/src/main/scala/kafka/server/AbstractFetcherThread.scala
##########
@@ -743,6 +743,18 @@ abstract class AbstractFetcherThread(name: String,
     } finally partitionMapLock.unlock()
   }
 
+  def removeAllPartitions(): Map[TopicPartition, PartitionFetchState] = {
+    partitionMapLock.lockInterruptibly()

Review comment:
       It might release the lock when trying to get all partitions  and use the 
result to remove might lead to inconsistency(when this fetcher add some 
partition right between the two process called by `AbstractFetcherManager`). So 
I make the process into one new method.
   Another point is that we don't need to do some filtering or get the state of 
thread one by one, but just iterate and return the copy of the whole 
`partitionStates.partitionStateMap`. I think it seems more efficient in 
realization.




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