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/09 14:59:45 UTC

[GitHub] [kafka] jsancio commented on a change in pull request #11189: KAFKA-13161: Always update the partition state

jsancio commented on a change in pull request #11189:
URL: https://github.com/apache/kafka/pull/11189#discussion_r685271449



##########
File path: core/src/main/scala/kafka/server/ReplicaManager.scala
##########
@@ -2204,27 +2204,32 @@ class ReplicaManager(val config: KafkaConfig,
 
           completeDelayedFetchOrProduceRequests(tp)
 
-          // Create the local replica even if the leader is unavailable. This is required
-          // to ensure that we include the partition's high watermark in the checkpoint
-          // file (see KAFKA-1647)
-          partition.createLogIfNotExists(isNew, false, offsetCheckpoints, Some(info.topicId))
-
           if (shuttingDown) {
             stateChangeLogger.trace(s"Unable to start fetching ${tp} with topic " +
               s"ID ${info.topicId} because the replica manager is shutting down.")
           } else {
             val listenerName = config.interBrokerListenerName.value()
             val leader = info.partition.leader
-            Option(newImage.cluster().broker(leader)).flatMap(_.node(listenerName).asScala) match {
-              case None => stateChangeLogger.trace(s"Unable to start fetching ${tp} " +
-                s"with topic ID ${info.topicId} from leader ${leader} because it is not " +
-                "alive.")
-              case Some(node) =>
-                val leaderEndPoint = new BrokerEndPoint(node.id(), node.host(), node.port())
-                val log = partition.localLogOrException
-                val fetchOffset = initialFetchOffset(log)
-                partitionsToMakeFollower.put(tp,
-                  InitialFetchState(leaderEndPoint, partition.getLeaderEpoch, fetchOffset))
+            val state = info.partition.toLeaderAndIsrPartitionState(tp, isNew)
+            if (partition.makeFollower(state, offsetCheckpoints, Some(info.topicId))) {
+              Option(newImage.cluster().broker(leader)).flatMap(_.node(listenerName).asScala) match {
+                case None =>
+                  stateChangeLogger.trace(
+                    s"Unable to start fetching ${tp} with topic ID ${info.topicId} from leader " +
+                    s"${leader} because it is not alive."
+                  )

Review comment:
       Created this issue to cover this case: https://issues.apache.org/jira/browse/KAFKA-13181




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