showuon commented on code in PR #15557:
URL: https://github.com/apache/kafka/pull/15557#discussion_r1546269825


##########
core/src/main/scala/kafka/server/ReplicaAlterLogDirsThread.scala:
##########
@@ -96,57 +97,55 @@ class ReplicaAlterLogDirsThread(name: String,
   }
 
   override def removePartitions(topicPartitions: Set[TopicPartition]): 
Map[TopicPartition, PartitionFetchState] = {
-    // Schedule assignment request to revert any queued request before 
cancelling
-    for {
-      topicPartition <- topicPartitions
-      partitionState <- partitionAssignmentRequestState(topicPartition)
-      if partitionState == QUEUED
-      partition = replicaMgr.getPartitionOrException(topicPartition)
-      topicId <- partition.topicId
-      directoryId <- partition.logDirectoryId()
-      topicIdPartition = new TopicIdPartition(topicId, 
topicPartition.partition())
-    } directoryEventHandler.handleAssignment(topicIdPartition, directoryId, () 
=> ())
+    for (topicPartition <- topicPartitions) {
+      // Revert any reassignments for partitions that did not complete the 
future replica promotion
+      val PromotionState(reassignmentState, topicId, originalDir) = 
this.promotionState(topicPartition)
+      if (reassignmentState.inconsistentMetadata) {
+        directoryEventHandler.handleAssignment(new TopicIdPartition(topicId, 
topicPartition.partition()), originalDir, () => ())

Review Comment:
   For (3), had a quick look, indeed it's not an easy test. 
   Could we, instead, test the logic in `ReplicationControlManager`? That is, 
add a test in `ReplicationControlManagerTest`, to make sure after receiving a 
reassignment request ->  log failure request -> reverted reassignment request, 
then, it should be able to elect another leader... etc?



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to