rondagostino commented on a change in pull request #10003: URL: https://github.com/apache/kafka/pull/10003#discussion_r567468635
########## File path: core/src/main/scala/kafka/server/ReplicaManager.scala ########## @@ -257,6 +265,25 @@ class ReplicaManager(val config: KafkaConfig, } } + // Changes are initially deferrable when using a Raft-based metadata quorum, and may flip-flop thereafter; + // changes are never deferrable when using ZooKeeper. When true, this indicates that we should transition online + // partitions to the deferred state if we see metadata with a different leader epoch. + @volatile private var changesDeferrable: Boolean = usingRaftMetadataQuorum + stateChangeLogger.info(s"Metadata changes deferrable=$changesDeferrable") + + private def confirmChangesNotDeferrableWithZooKeeper(): Unit = { + if (changesDeferrable) { + throw new IllegalStateException("Partition metadata changes should never be deferrable when using ZooKeeper") + } + } + + def deferrableMetadataChanges(): Unit = { + replicaStateChangeLock synchronized { Review comment: It isn't entirely clear since there are places where this lock is acquired that we won't implement for the initial version of a Raft-based metadata quorum (e.g. handling log dir failure). I think it's a good point that we should check here, though, because we must never make changes deferrable if we are using ZooKeeper. So I added the check. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org