This is an automated email from the ASF dual-hosted git repository.

HTHou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 1188db9b130 Fix max data region group quota calculation (#18263)
1188db9b130 is described below

commit 1188db9b130d883f0b89234802ff09f7bedeae3b
Author: libo <[email protected]>
AuthorDate: Tue Jul 21 16:07:59 2026 +0800

    Fix max data region group quota calculation (#18263)
---
 .../IoTDBDatabaseAutoDataRegionGroupQuotaIT.java   | 91 ++++++++++++++++++++++
 .../manager/schema/ClusterSchemaManager.java       |  4 +-
 2 files changed, 94 insertions(+), 1 deletion(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseAutoDataRegionGroupQuotaIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseAutoDataRegionGroupQuotaIT.java
new file mode 100644
index 00000000000..4d2fd8c780c
--- /dev/null
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseAutoDataRegionGroupQuotaIT.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.relational.it.schema;
+
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.db.it.utils.TestUtils;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.TableClusterIT;
+import org.apache.iotdb.itbase.env.BaseEnv;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Collections;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({TableClusterIT.class})
+public class IoTDBDatabaseAutoDataRegionGroupQuotaIT {
+
+  private static final int CONFIG_NODE_NUM = 1;
+  private static final int DATA_NODE_NUM = 3;
+  private static final int SCHEMA_REPLICATION_FACTOR = 3;
+  private static final int DATA_REPLICATION_FACTOR = 1;
+  private static final int DATA_REGION_PER_DATA_NODE = 2;
+
+  @Before
+  public void setUp() throws Exception {
+    EnvFactory.getEnv()
+        .getConfig()
+        .getCommonConfig()
+        .setSchemaRegionGroupExtensionPolicy("CUSTOM")
+        .setDataRegionGroupExtensionPolicy("AUTO")
+        
.setSchemaRegionConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS)
+        .setDefaultSchemaRegionGroupNumPerDatabase(1)
+        .setDefaultDataRegionGroupNumPerDatabase(1)
+        .setSchemaReplicationFactor(SCHEMA_REPLICATION_FACTOR)
+        .setDataReplicationFactor(DATA_REPLICATION_FACTOR)
+        .setDataRegionPerDataNode(DATA_REGION_PER_DATA_NODE);
+    EnvFactory.getEnv().initClusterEnvironment(CONFIG_NODE_NUM, DATA_NODE_NUM);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void testMaxDataRegionGroupNumUsesDataReplicationFactor() throws 
SQLException {
+    try (final Connection connection =
+            EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+        final Statement statement = connection.createStatement()) {
+      final int expectedMaxDataRegionGroupNum =
+          (int)
+              Math.ceil(
+                  (double) DATA_REGION_PER_DATA_NODE * DATA_NODE_NUM / 
DATA_REPLICATION_FACTOR);
+
+      statement.execute("create database test_data_region_rf 
with(max_schema_region_group_num=2)");
+
+      TestUtils.assertResultSetEqual(
+          statement.executeQuery(
+              "select database, max_schema_region_group_num, 
max_data_region_group_num "
+                  + "from information_schema.databases where database = 
'test_data_region_rf'"),
+          "database,max_schema_region_group_num,max_data_region_group_num,",
+          Collections.singleton("test_data_region_rf,2," + 
expectedMaxDataRegionGroupNum + ","));
+    }
+  }
+}
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 a66b88f0a10..357c14eca4a 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
@@ -603,7 +603,9 @@ public class ClusterSchemaManager {
                 ? dataNodeNum
                 : (CONF.getDataRegionPerDataNode() == 0 ? totalCpuCoreNum : 
dataNodeNum),
             databaseNum,
-            databaseSchema.getSchemaReplicationFactor(),
+            (consensusGroupType == TConsensusGroupType.SchemaRegion)
+                ? databaseSchema.getSchemaReplicationFactor()
+                : databaseSchema.getDataReplicationFactor(),
             allocatedRegionGroupCount);
     LOGGER.info(
         (consensusGroupType == TConsensusGroupType.SchemaRegion)

Reply via email to