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



##########
File path: core/src/main/scala/kafka/server/ReplicaManager.scala
##########
@@ -1405,11 +1393,28 @@ class ReplicaManager(val config: KafkaConfig,
                   s"leader epoch $currentLeaderEpoch")
                 responseMap.put(topicPartition, Errors.STALE_CONTROLLER_EPOCH)
               } else {
-                stateChangeLogger.info(s"Ignoring LeaderAndIsr request from " +
-                  s"controller $controllerId with correlation id 
$correlationId " +
-                  s"epoch $controllerEpoch for partition $topicPartition since 
its associated " +
-                  s"leader epoch $requestLeaderEpoch matches the current 
leader epoch")
-                responseMap.put(topicPartition, Errors.STALE_CONTROLLER_EPOCH)
+                // The controller may send LeaderAndIsr to upgrade to using 
topic IDs without bumping the epoch.
+                val error = requestTopicId match {
+                  case Some(topicId) if partition.log.isEmpty =>
+                    // We wanted to assign the topic ID to the log, but the 
log was unavailable.
+                    stateChangeLogger.info(s"Tried to update log for 
$topicPartition to assign topic ID " +
+                      s"$topicId from LeaderAndIsr request from controller 
$controllerId with correlation" +
+                      s" id $correlationId epoch $controllerEpoch")
+                    Errors.KAFKA_STORAGE_ERROR

Review comment:
       Hmm, I am not sure about this. If you look at `localLogOrException`, for 
example, it would return `NotLeader` if the log is not defined. In this method, 
we already have the `replicaStateChangeLock`, so that protects us from a 
concurrent call to `markPartitionOffline`. As far as I can tell, the only time 
we might not have a `Log` defined for the partition is if it has not been 
created yet or if it has been deleted. But given that we have already verified 
that the epoch of the request matches the local epoch, neither case seems 
possible. My suggestion would be to remove this check and use 
`localLogOrException` to make it clear that the log is expected to exist at 
this point.




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