rondagostino commented on a change in pull request #10008:
URL: https://github.com/apache/kafka/pull/10008#discussion_r569444234



##########
File path: 
core/src/main/scala/kafka/coordinator/group/GroupMetadataManager.scala
##########
@@ -78,7 +78,20 @@ class GroupMetadataManager(brokerId: Int,
   private val shuttingDown = new AtomicBoolean(false)
 
   /* number of partitions for the consumer metadata topic */
-  private val groupMetadataTopicPartitionCount = 
getGroupMetadataTopicPartitionCount
+  private var _groupMetadataTopicPartitionCount: Option[Int] = Option.empty // 
lazy, once-only evaluation
+  private def groupMetadataTopicPartitionCount: Int = {
+    _groupMetadataTopicPartitionCount match {
+      case Some(partitionCount) => partitionCount
+      case None => synchronized { // make sure we only invoke the function once
+        _groupMetadataTopicPartitionCount match {
+          case Some(partitionCount) => partitionCount // another thread beat 
us to it
+          case None =>
+            _groupMetadataTopicPartitionCount = 
Some(offsetsTopicPartitionCountFunc())

Review comment:
       This is no longer na issue since we invoke the function once in 
`startup()`.  We do it again in `TransactionStateManager` whenever we become 
leader for a partition, but that happens in the scheduler thread where any 
exception will be caught/logged.




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


Reply via email to