From b5d9123d0ab4348b810d9cc49f2599c2a3d8e967 Mon Sep 17 00:00:00 2001 From: Caideyipi <87789683+Caideyipi@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:30:59 +0800 Subject: [PATCH 1/2] Update ClusterSchemaManager.java --- .../manager/schema/ClusterSchemaManager.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 9a6c06c26733..8b643f84da16 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -520,9 +520,16 @@ public synchronized void adjustMaxRegionGroupNum() { // Adjust maxDataRegionGroupNum for each Database. // All Databases share the DataNodes equally. // The allocated DataRegionGroups will not be shrunk. - final int allocatedDataRegionGroupCount = - getPartitionManager() - .getRegionGroupCount(databaseSchema.getName(), TConsensusGroupType.DataRegion); + final int allocatedDataRegionGroupCount; + try { + allocatedDataRegionGroupCount = + getPartitionManager() + .getRegionGroupCount(databaseSchema.getName(), TConsensusGroupType.DataRegion); + } catch (final DatabaseNotExistsException e) { + // ignore the pre deleted database + continue; + } + final int maxDataRegionGroupNum = calcMaxRegionGroupNum( databaseSchema.getMinDataRegionGroupNum(), From 0538624465597dde0bfe719b15eb5bcbcdc86834 Mon Sep 17 00:00:00 2001 From: Caideyipi <87789683+Caideyipi@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:32:46 +0800 Subject: [PATCH 2/2] Update ClusterSchemaManager.java --- .../manager/schema/ClusterSchemaManager.java | 108 +++++++++--------- 1 file changed, 52 insertions(+), 56 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 8b643f84da16..8e4bab6b0d49 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -490,66 +490,62 @@ public synchronized void adjustMaxRegionGroupNum() { continue; } + // Adjust maxSchemaRegionGroupNum for each Database. + // All Databases share the DataNodes equally. + // The allocated SchemaRegionGroups will not be shrunk. + final int allocatedSchemaRegionGroupCount; try { - // Adjust maxSchemaRegionGroupNum for each Database. - // All Databases share the DataNodes equally. - // The allocated SchemaRegionGroups will not be shrunk. - final int allocatedSchemaRegionGroupCount; - try { - allocatedSchemaRegionGroupCount = - getPartitionManager() - .getRegionGroupCount(databaseSchema.getName(), TConsensusGroupType.SchemaRegion); - } catch (final DatabaseNotExistsException e) { - // ignore the pre deleted database - continue; - } - - final int maxSchemaRegionGroupNum = - calcMaxRegionGroupNum( - databaseSchema.getMinSchemaRegionGroupNum(), - SCHEMA_REGION_PER_DATA_NODE, - dataNodeNum, - databaseNum, - databaseSchema.getSchemaReplicationFactor(), - allocatedSchemaRegionGroupCount); - LOGGER.info( - "[AdjustRegionGroupNum] The maximum number of SchemaRegionGroups for Database: {} is adjusted to: {}", - databaseSchema.getName(), - maxSchemaRegionGroupNum); - - // Adjust maxDataRegionGroupNum for each Database. - // All Databases share the DataNodes equally. - // The allocated DataRegionGroups will not be shrunk. - final int allocatedDataRegionGroupCount; - try { - allocatedDataRegionGroupCount = - getPartitionManager() - .getRegionGroupCount(databaseSchema.getName(), TConsensusGroupType.DataRegion); - } catch (final DatabaseNotExistsException e) { - // ignore the pre deleted database - continue; - } + allocatedSchemaRegionGroupCount = + getPartitionManager() + .getRegionGroupCount(databaseSchema.getName(), TConsensusGroupType.SchemaRegion); + } catch (final DatabaseNotExistsException e) { + // ignore the pre deleted database + continue; + } - final int maxDataRegionGroupNum = - calcMaxRegionGroupNum( - databaseSchema.getMinDataRegionGroupNum(), - DATA_REGION_PER_DATA_NODE == 0 - ? CONF.getDataRegionPerDataNodeProportion() - : DATA_REGION_PER_DATA_NODE, - DATA_REGION_PER_DATA_NODE == 0 ? totalCpuCoreNum : dataNodeNum, - databaseNum, - databaseSchema.getDataReplicationFactor(), - allocatedDataRegionGroupCount); - LOGGER.info( - "[AdjustRegionGroupNum] The maximum number of DataRegionGroups for Database: {} is adjusted to: {}", - databaseSchema.getName(), - maxDataRegionGroupNum); - - adjustMaxRegionGroupNumPlan.putEntry( - databaseSchema.getName(), new Pair<>(maxSchemaRegionGroupNum, maxDataRegionGroupNum)); + final int maxSchemaRegionGroupNum = + calcMaxRegionGroupNum( + databaseSchema.getMinSchemaRegionGroupNum(), + SCHEMA_REGION_PER_DATA_NODE, + dataNodeNum, + databaseNum, + databaseSchema.getSchemaReplicationFactor(), + allocatedSchemaRegionGroupCount); + LOGGER.info( + "[AdjustRegionGroupNum] The maximum number of SchemaRegionGroups for Database: {} is adjusted to: {}", + databaseSchema.getName(), + maxSchemaRegionGroupNum); + + // Adjust maxDataRegionGroupNum for each Database. + // All Databases share the DataNodes equally. + // The allocated DataRegionGroups will not be shrunk. + final int allocatedDataRegionGroupCount; + try { + allocatedDataRegionGroupCount = + getPartitionManager() + .getRegionGroupCount(databaseSchema.getName(), TConsensusGroupType.DataRegion); } catch (final DatabaseNotExistsException e) { - LOGGER.warn("Adjust maxRegionGroupNum failed because Database doesn't exist", e); + // ignore the pre deleted database + continue; } + + final int maxDataRegionGroupNum = + calcMaxRegionGroupNum( + databaseSchema.getMinDataRegionGroupNum(), + DATA_REGION_PER_DATA_NODE == 0 + ? CONF.getDataRegionPerDataNodeProportion() + : DATA_REGION_PER_DATA_NODE, + DATA_REGION_PER_DATA_NODE == 0 ? totalCpuCoreNum : dataNodeNum, + databaseNum, + databaseSchema.getDataReplicationFactor(), + allocatedDataRegionGroupCount); + LOGGER.info( + "[AdjustRegionGroupNum] The maximum number of DataRegionGroups for Database: {} is adjusted to: {}", + databaseSchema.getName(), + maxDataRegionGroupNum); + + adjustMaxRegionGroupNumPlan.putEntry( + databaseSchema.getName(), new Pair<>(maxSchemaRegionGroupNum, maxDataRegionGroupNum)); } try { getConsensusManager().write(adjustMaxRegionGroupNumPlan);