junrao commented on code in PR #17563:
URL: https://github.com/apache/kafka/pull/17563#discussion_r1813912519


##########
core/src/main/scala/kafka/server/ReplicaManager.scala:
##########
@@ -657,7 +661,7 @@ class ReplicaManager(val config: KafkaConfig,
       }
       // If we were the leader, we may have some operations still waiting for 
completion.
       // We force completion to prevent them from timing out.
-      completeDelayedOperationsWhenNotPartitionLeader(topicPartition, topicId)
+      completeDelayedOperationsWhenNotPartitionLeader(topicPartition, topicId, 
isStopReplica = true)

Review Comment:
   We can move this check inside `if (stopPartition.deleteLocalLog) `.



##########
core/src/main/scala/kafka/server/ReplicaManager.scala:
##########
@@ -3072,7 +3076,7 @@ class ReplicaManager(val config: KafkaConfig,
       stateChangeLogger.info(s"Started fetchers as part of become-follower for 
${partitionsToStartFetching.size} partitions")
 
       partitionsToStartFetching.foreach{ case (topicPartition, partition) =>
-        completeDelayedOperationsWhenNotPartitionLeader(topicPartition, 
partition.topicId)}
+        completeDelayedOperationsWhenNotPartitionLeader(topicPartition, 
partition.topicId, isStopReplica = false)}

Review Comment:
   We can optimize this a bit more. We only need to make this call if the 
replica is now a follower and previously a leader.



##########
core/src/main/scala/kafka/server/ReplicaManager.scala:
##########
@@ -469,14 +469,18 @@ class ReplicaManager(val config: KafkaConfig,
     })
   }
 
-  private def completeDelayedOperationsWhenNotPartitionLeader(topicPartition: 
TopicPartition, topicId: Option[Uuid]): Unit = {
+  private def completeDelayedOperationsWhenNotPartitionLeader(topicPartition: 
TopicPartition, topicId: Option[Uuid],

Review Comment:
   Perhaps it's clearer to split this into 2 methods, one for NotLeader and 
another NotReplica?



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