You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/08/19 01:15:24 UTC

[GitHub] [kafka] hachikuji commented on a change in pull request #11225: MINOR; Small optimizations in `ReplicaManager#becomeLeaderOrFollower`

hachikuji commented on a change in pull request #11225:
URL: https://github.com/apache/kafka/pull/11225#discussion_r691703790



##########
File path: core/src/main/scala/kafka/server/ReplicaManager.scala
##########
@@ -1436,17 +1438,15 @@ class ReplicaManager(val config: KafkaConfig,
 
           leaderAndIsrRequest.partitionStates.forEach { partitionState =>
             val topicPartition = new TopicPartition(partitionState.topicName, partitionState.partitionIndex)
-            /*
-           * If there is offline log directory, a Partition object may have been created by getOrCreatePartition()
-           * before getOrCreateReplica() failed to create local replica due to KafkaStorageException.
-           * In this case ReplicaManager.allPartitions will map this topic-partition to an empty Partition object.
-           * we need to map this topic-partition to OfflinePartition instead.
-           */
+            // If there is offline log directory, a Partition object may have been created by getOrCreatePartition()

Review comment:
       nit: If there is _an_ offline log directory?

##########
File path: core/src/main/scala/kafka/server/ReplicaManager.scala
##########
@@ -1436,17 +1438,15 @@ class ReplicaManager(val config: KafkaConfig,
 
           leaderAndIsrRequest.partitionStates.forEach { partitionState =>

Review comment:
       This logic is a bit strange. It sounds like we need are trying to handle the case where we fail to create the log after we have already created the partition. Would it make more sense to handle this in `getOrCreatePartition` if an exception is raised?

##########
File path: core/src/main/scala/kafka/server/ReplicaManager.scala
##########
@@ -1436,17 +1438,15 @@ class ReplicaManager(val config: KafkaConfig,
 
           leaderAndIsrRequest.partitionStates.forEach { partitionState =>
             val topicPartition = new TopicPartition(partitionState.topicName, partitionState.partitionIndex)
-            /*
-           * If there is offline log directory, a Partition object may have been created by getOrCreatePartition()
-           * before getOrCreateReplica() failed to create local replica due to KafkaStorageException.
-           * In this case ReplicaManager.allPartitions will map this topic-partition to an empty Partition object.
-           * we need to map this topic-partition to OfflinePartition instead.
-           */
+            // If there is offline log directory, a Partition object may have been created by getOrCreatePartition()
+            // before getOrCreateReplica() failed to create local replica due to KafkaStorageException.

Review comment:
       Hmm, `getOrCreateReplica` no longer exists. Maybe `createLogIfNotExists` is the replacement?




-- 
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-unsubscribe@kafka.apache.org

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