hachikuji commented on code in PR #12071: URL: https://github.com/apache/kafka/pull/12071#discussion_r855450737
########## core/src/main/scala/kafka/cluster/Partition.scala: ########## @@ -251,8 +251,9 @@ class Partition(val topicPartition: TopicPartition, // lock to prevent the follower replica log update while checking if the log dir could be replaced with future log. private val futureLogLock = new Object() - private var zkVersion: Int = LeaderAndIsr.initialZKVersion - @volatile private var leaderEpoch: Int = LeaderAndIsr.initialLeaderEpoch - 1 + // The current epoch for the partition for KRaft controllers. The current ZK version for the legacy controllers. + private var partitionEpoch: Int = LeaderAndIsr.InitialPartitionEpoch Review Comment: Either that or we should try to document the expectation that we have the lock. One thing that makes me a little uncomfortable in regard to these volatile fields is any expectation of consistency between them. Maybe a potential refactor for a subsequent patch could be to pull these fields into `PartitionState` so that the state can be updated atomically. What do you think? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
