This is an automated email from the ASF dual-hosted git repository.
tanxinyu 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 cea15bbe37d [IOTDB-6283] Adjust the leader election waiting time when
create RegionGroup (#11804)
cea15bbe37d is described below
commit cea15bbe37ddf46faee1978a95e731e92ead8d6c
Author: Yongzao <[email protected]>
AuthorDate: Fri Dec 29 10:45:00 2023 +0800
[IOTDB-6283] Adjust the leader election waiting time when create
RegionGroup (#11804)
---
.../org/apache/iotdb/confignode/manager/load/cache/LoadCache.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/LoadCache.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/LoadCache.java
index f9a208d47c5..c0f9312b77e 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/LoadCache.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/LoadCache.java
@@ -27,6 +27,7 @@ import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.commons.cluster.NodeType;
import org.apache.iotdb.commons.cluster.RegionStatus;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.confignode.conf.ConfigNodeConfig;
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
import org.apache.iotdb.confignode.manager.IManager;
@@ -65,6 +66,10 @@ public class LoadCache {
private static final ConfigNodeConfig CONF =
ConfigNodeDescriptor.getInstance().getConf();
private static final long HEARTBEAT_INTERVAL =
CONF.getHeartbeatIntervalInMs();
+ private static final long LEADER_ELECTION_WAITING_TIMEOUT =
+ Math.min(
+ 2 * CONF.getSchemaRegionRatisRpcLeaderElectionTimeoutMaxMs(),
+
CommonDescriptor.getInstance().getConfig().getConnectionTimeoutInMS());
// Map<NodeId, INodeCache>
private final Map<Integer, BaseNodeCache> nodeCacheMap;
@@ -536,8 +541,9 @@ public class LoadCache {
* @param regionGroupIds Specified RegionGroupIds
*/
public void waitForLeaderElection(List<TConsensusGroupId> regionGroupIds) {
+ long startTime = System.currentTimeMillis();
LOGGER.info("[RegionElection] Wait for leader election of RegionGroups:
{}", regionGroupIds);
- for (int retry = 0; retry < 10; retry++) {
+ while (System.currentTimeMillis() - startTime <=
LEADER_ELECTION_WAITING_TIMEOUT) {
AtomicBoolean allRegionLeaderElected = new AtomicBoolean(true);
regionGroupIds.forEach(
regionGroupId -> {