mumrah commented on a change in pull request #10003: URL: https://github.com/apache/kafka/pull/10003#discussion_r567070588
########## 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: Is it the case that whenever we grab this lock we want to assert that we're in a legal state wrt ZK and `changesDeferrable`? If that's the case, we might want to make a note of it where we define `replicaStateChangeLock`. Alternatively, maybe we could put this behind some helper function that grabs the lock and checks our state. ---------------------------------------------------------------- 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