You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2023/05/31 06:14:32 UTC

[iotdb] branch rel/1.1 updated: [To rel/1.1][IOTDB-5934] Optimize cluster partition policy (#9977)

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

tanxinyu pushed a commit to branch rel/1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/1.1 by this push:
     new 43aa12b388c [To rel/1.1][IOTDB-5934] Optimize cluster partition policy (#9977)
43aa12b388c is described below

commit 43aa12b388c31f9506cc03ae9ed64fadd79e3456
Author: YongzaoDan <33...@users.noreply.github.com>
AuthorDate: Wed May 31 14:14:27 2023 +0800

    [To rel/1.1][IOTDB-5934] Optimize cluster partition policy (#9977)
---
 .../iotdb/confignode/conf/ConfigNodeConfig.java    |  4 +--
 .../confignode/conf/SystemPropertiesUtils.java     | 38 ++++++++++++----------
 .../manager/partition/PartitionManager.java        | 16 ++++++++-
 .../it/partition/IoTDBPartitionGetterIT.java       |  4 +--
 .../confignode/it/utils/ConfigNodeTestUtils.java   |  2 +-
 .../resources/conf/iotdb-common.properties         |  2 +-
 6 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
index 4a181681852..0b2b2b89828 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
@@ -68,8 +68,8 @@ public class ConfigNodeConfig {
   /** Default number of DataRegion replicas */
   private int dataReplicationFactor = 1;
 
-  /** Number of SeriesPartitionSlots per StorageGroup */
-  private int seriesSlotNum = 10000;
+  /** Number of SeriesPartitionSlots per Database */
+  private int seriesSlotNum = 1000;
 
   /** SeriesPartitionSlot executor class */
   private String seriesPartitionExecutorClass =
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java b/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java
index 6847e7dc937..5a304fe610d 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java
@@ -117,6 +117,9 @@ public class SystemPropertiesUtils {
       }
     }
 
+    final String format =
+        "[SystemProperties] The parameter \"{}\" can't be modified after first startup."
+            + " Your configuration: {} will be forced update to: {}";
     // Consensus protocol configuration
     String configNodeConsensusProtocolClass =
         systemProperties.getProperty("config_node_consensus_protocol_class", null);
@@ -124,11 +127,12 @@ public class SystemPropertiesUtils {
       needReWrite = true;
     } else if (!configNodeConsensusProtocolClass.equals(
         conf.getConfigNodeConsensusProtocolClass())) {
-      throw new ConfigurationException(
+      LOGGER.warn(
+          format,
           "config_node_consensus_protocol_class",
           conf.getConfigNodeConsensusProtocolClass(),
-          configNodeConsensusProtocolClass,
-          "config_node_consensus_protocol_class can't be modified after first startup");
+          configNodeConsensusProtocolClass);
+      conf.setConfigNodeConsensusProtocolClass(configNodeConsensusProtocolClass);
     }
 
     String dataRegionConsensusProtocolClass =
@@ -137,11 +141,12 @@ public class SystemPropertiesUtils {
       needReWrite = true;
     } else if (!dataRegionConsensusProtocolClass.equals(
         conf.getDataRegionConsensusProtocolClass())) {
-      throw new ConfigurationException(
+      LOGGER.warn(
+          format,
           "data_region_consensus_protocol_class",
           conf.getDataRegionConsensusProtocolClass(),
-          dataRegionConsensusProtocolClass,
-          "data_region_consensus_protocol_class can't be modified after first startup");
+          dataRegionConsensusProtocolClass);
+      conf.setDataRegionConsensusProtocolClass(dataRegionConsensusProtocolClass);
     }
 
     String schemaRegionConsensusProtocolClass =
@@ -150,11 +155,12 @@ public class SystemPropertiesUtils {
       needReWrite = true;
     } else if (!schemaRegionConsensusProtocolClass.equals(
         conf.getSchemaRegionConsensusProtocolClass())) {
-      throw new ConfigurationException(
+      LOGGER.warn(
+          format,
           "schema_region_consensus_protocol_class",
           conf.getSchemaRegionConsensusProtocolClass(),
-          schemaRegionConsensusProtocolClass,
-          "schema_region_consensus_protocol_class can't be modified after first startup");
+          schemaRegionConsensusProtocolClass);
+      conf.setSchemaRegionConsensusProtocolClass(schemaRegionConsensusProtocolClass);
     }
 
     // PartitionSlot configuration
@@ -164,11 +170,8 @@ public class SystemPropertiesUtils {
       int seriesPartitionSlotNum =
           Integer.parseInt(systemProperties.getProperty("series_partition_slot_num"));
       if (seriesPartitionSlotNum != conf.getSeriesSlotNum()) {
-        throw new ConfigurationException(
-            "series_partition_slot_num",
-            String.valueOf(conf.getSeriesSlotNum()),
-            String.valueOf(seriesPartitionSlotNum),
-            "series_partition_slot_num can't be modified after first startup");
+        LOGGER.warn(format, "series_slot_num", conf.getSeriesSlotNum(), seriesPartitionSlotNum);
+        conf.setSeriesSlotNum(seriesPartitionSlotNum);
       }
     }
 
@@ -178,11 +181,12 @@ public class SystemPropertiesUtils {
       needReWrite = true;
     } else if (!Objects.equals(
         seriesPartitionSlotExecutorClass, conf.getSeriesPartitionExecutorClass())) {
-      throw new ConfigurationException(
+      LOGGER.warn(
+          format,
           "series_partition_executor_class",
           conf.getSeriesPartitionExecutorClass(),
-          seriesPartitionSlotExecutorClass,
-          "series_partition_executor_class can't be modified after first startup");
+          seriesPartitionSlotExecutorClass);
+      conf.setSeriesPartitionExecutorClass(seriesPartitionSlotExecutorClass);
     }
 
     if (needReWrite) {
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java
index d314673893d..85d9fed6b22 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java
@@ -208,6 +208,13 @@ public class PartitionManager {
     // by the number of SeriesPartitionSlots,
     // the number of serialized CreateSchemaPartitionReqs is acceptable.
     synchronized (this) {
+      // Here we should check again if the SchemaPartition
+      // has been created by other threads to improve concurrent performance
+      resp = (SchemaPartitionResp) getSchemaPartition(req);
+      if (resp.isAllPartitionsExist()) {
+        return resp;
+      }
+
       // Filter unassigned SchemaPartitionSlots
       Map<String, List<TSeriesPartitionSlot>> unassignedSchemaPartitionSlotsMap =
           partitionInfo.filterUnassignedSchemaPartitionSlots(req.getPartitionSlotsMap());
@@ -261,7 +268,7 @@ public class PartitionManager {
     resp = (SchemaPartitionResp) getSchemaPartition(req);
     if (!resp.isAllPartitionsExist()) {
       LOGGER.error(
-          "Lacked some SchemaPartition allocation result in the response of getOrCreateDataPartition method");
+          "Lacked some SchemaPartition allocation result in the response of getOrCreateSchemaPartition method");
       resp.setStatus(
           new TSStatus(TSStatusCode.LACK_PARTITION_ALLOCATION.getStatusCode())
               .setMessage("Lacked some SchemaPartition allocation result in the response"));
@@ -307,6 +314,13 @@ public class PartitionManager {
     // by the number of SeriesPartitionSlots,
     // the number of serialized CreateDataPartitionReqs is acceptable.
     synchronized (this) {
+      // Here we should check again if the DataPartition
+      // has been created by other threads to improve concurrent performance
+      resp = (DataPartitionResp) getDataPartition(req);
+      if (resp.isAllPartitionsExist()) {
+        return resp;
+      }
+
       // Filter unassigned DataPartitionSlots
       Map<String, Map<TSeriesPartitionSlot, TTimeSlotList>> unassignedDataPartitionSlotsMap =
           partitionInfo.filterUnassignedDataPartitionSlots(req.getPartitionSlotsMap());
diff --git a/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java b/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java
index 96c7ac77150..b8f662cb9c6 100644
--- a/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java
@@ -459,7 +459,7 @@ public class IoTDBPartitionGetterIT {
       Assert.assertEquals(
           TSStatusCode.SUCCESS_STATUS.getStatusCode(), getSeriesSlotListResp.status.getCode());
       Assert.assertEquals(
-          testSeriesPartitionSlotNum + 2, getSeriesSlotListResp.getSeriesSlotListSize());
+          testSeriesPartitionSlotNum, getSeriesSlotListResp.getSeriesSlotListSize());
 
       getSeriesSlotListReq.setType(TConsensusGroupType.ConfigRegion);
 
@@ -467,7 +467,7 @@ public class IoTDBPartitionGetterIT {
       Assert.assertEquals(
           TSStatusCode.SUCCESS_STATUS.getStatusCode(), getSeriesSlotListResp.status.getCode());
       Assert.assertEquals(
-          testSeriesPartitionSlotNum + 2, getSeriesSlotListResp.getSeriesSlotListSize());
+          testSeriesPartitionSlotNum, getSeriesSlotListResp.getSeriesSlotListSize());
 
       getSeriesSlotListReq.setType(TConsensusGroupType.SchemaRegion);
 
diff --git a/integration-test/src/test/java/org/apache/iotdb/confignode/it/utils/ConfigNodeTestUtils.java b/integration-test/src/test/java/org/apache/iotdb/confignode/it/utils/ConfigNodeTestUtils.java
index b3123838fcf..e1588956e2f 100644
--- a/integration-test/src/test/java/org/apache/iotdb/confignode/it/utils/ConfigNodeTestUtils.java
+++ b/integration-test/src/test/java/org/apache/iotdb/confignode/it/utils/ConfigNodeTestUtils.java
@@ -201,7 +201,7 @@ public class ConfigNodeTestUtils {
         "org.apache.iotdb.consensus.simple.SimpleConsensus");
     clusterParameters.setSchemaRegionConsensusProtocolClass(
         "org.apache.iotdb.consensus.simple.SimpleConsensus");
-    clusterParameters.setSeriesPartitionSlotNum(10000);
+    clusterParameters.setSeriesPartitionSlotNum(1000);
     clusterParameters.setSeriesPartitionExecutorClass(
         "org.apache.iotdb.commons.partition.executor.hash.BKDRHashExecutor");
     clusterParameters.setDefaultTTL(Long.MAX_VALUE);
diff --git a/node-commons/src/assembly/resources/conf/iotdb-common.properties b/node-commons/src/assembly/resources/conf/iotdb-common.properties
index 0e5060c9ff1..643e0981b3c 100644
--- a/node-commons/src/assembly/resources/conf/iotdb-common.properties
+++ b/node-commons/src/assembly/resources/conf/iotdb-common.properties
@@ -71,7 +71,7 @@ cluster_name=defaultCluster
 # And these parameters should be consistent within the ConfigNodeGroup.
 # Number of SeriesPartitionSlots per Database
 # Datatype: Integer
-# series_slot_num=10000
+# series_slot_num=1000
 
 # SeriesPartitionSlot executor class
 # These hashing algorithms are currently supported: