mcvsubbu commented on a change in pull request #7066: URL: https://github.com/apache/pinot/pull/7066#discussion_r683662750
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/segment/SegmentSizeBasedFlushThresholdUpdater.java ########## @@ -102,8 +106,14 @@ public synchronized void updateFlushThreshold(PartitionLevelStreamConfig streamC // less same characteristics at any one point in time). // However, when we start a new table or change controller mastership, we can have any partition completing first. // It is best to learn the ratio as quickly as we can, so we allow any partition to supply the value. - // FIXME: The stream may not have partition "0" - if (new LLCSegmentName(newSegmentName).getPartitionGroupId() == 0 || _latestSegmentRowsToSizeRatio == 0) { + + // Partition group id 0 might not be available always. We take the smallest available partition id in that case to update the threshold + int smallestAvailablePartitionGroupId = + partitionGroupMetadataList.stream().min(Comparator.comparingInt(PartitionGroupMetadata::getPartitionGroupId)) + .map(PartitionGroupMetadata::getPartitionGroupId).orElseGet(() -> 0); Review comment: Also, it looks like as long as there are non-zero partitions in the metadata list, we should get some min or another. So, the case of no partitions being available in metadata list can potentially be handled. Better yet, a pre-condition that it is not empty. Speaking of which, it is possible that it is empty? Say, one partition got started, and the administrator closed it for some reason. So, the current list of partitions is empty. Possible, right? if so, then we should update the ratio (with whatever partition ID is completing) ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java ########## @@ -1184,7 +1187,8 @@ private String setupNewPartitionGroup(TableConfig tableConfig, PartitionLevelStr CommittingSegmentDescriptor committingSegmentDescriptor = new CommittingSegmentDescriptor(null, startOffset, 0); createNewSegmentZKMetadata(tableConfig, streamConfig, newLLCSegmentName, creationTimeMs, - committingSegmentDescriptor, null, instancePartitions, numPartitionGroups, numReplicas); + committingSegmentDescriptor, null, instancePartitions, numPartitionGroups, numReplicas, + Collections.singletonList(partitionGroupMetadata)); Review comment: +1 -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org