d-wang-commit commented on code in PR #18692:
URL: https://github.com/apache/iotdb/pull/18692#discussion_r4078528246
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java:
##########
@@ -645,16 +651,62 @@ private TSStatus extendRegionGroupIfNecessary(
return result;
}
+ private TSStatus proactiveExtendRegionGroupIfNecessary(
+ final Map<String, ? extends Collection<TSeriesPartitionSlot>>
unassignedPartitionSlotsMap,
+ final TConsensusGroupType consensusGroupType)
+ throws DatabaseNotExistsException, NotEnoughDataNodeException {
+ final Map<String, Integer> allotmentMap = new HashMap<>();
+ for (Map.Entry<String, ? extends Collection<TSeriesPartitionSlot>> entry :
+ unassignedPartitionSlotsMap.entrySet()) {
+ final String database = entry.getKey();
+ final int maxRegionGroupCount =
+ getClusterSchemaManager().getMaxRegionGroupNum(database,
consensusGroupType);
+ final int minRegionGroupCount =
+ getClusterSchemaManager().getMinRegionGroupNum(database,
consensusGroupType);
+ final int allocatedRegionGroupCount =
+ partitionInfo.getRegionGroupCount(database, consensusGroupType);
+ // As with AUTO, grow toward the minimum by at most the number of
pending series slots.
+ // An existing data slot with new time partitions also contributes to
this incremental growth.
+ final int minimumRegionGroupTarget =
+ Math.min(
+ minRegionGroupCount,
+ allocatedRegionGroupCount + new
HashSet<>(entry.getValue()).size());
+ final int targetRegionGroupCount =
+ Math.min(
+ maxRegionGroupCount,
+ Math.max(
+ minimumRegionGroupTarget,
+ partitionInfo.getSeriesPartitionSlotsCount(
+ database, consensusGroupType, entry.getValue())));
+ // Also allocate one group per active series slot, up to the same
maximum as AUTO.
+ // Existing groups are retained when the maximum decreases or the policy
changes.
+ if (allocatedRegionGroupCount < targetRegionGroupCount) {
+ allotmentMap.put(database, targetRegionGroupCount -
allocatedRegionGroupCount);
+ } else if (!entry.getValue().isEmpty()
+ && allocatedRegionGroupCount > 0
+ && allocatedRegionGroupCount < maxRegionGroupCount
+ && partitionInfo.getAllRegionGroupIds(database,
consensusGroupType).stream()
+ .allMatch(
+ regionGroupId ->
+ RegionGroupStatus.Disabled.equals(
+
getLoadManager().getRegionGroupStatus(regionGroupId)))) {
Review Comment:
The max region group number caps any extra allocation. Also, a successfully
created group is immediately activated, so subsequent requests no longer
satisfy the “all disabled” condition. Given the bounded impact, we’ll keep the
current implementation
--
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]