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 2021/03/08 08:51:48 UTC

[iotdb] branch cluster_remove_unnecessary_sync_meta_leader_ created (now 2a58d9d)

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

tanxinyu pushed a change to branch cluster_remove_unnecessary_sync_meta_leader_
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at 2a58d9d  remove unnecessary sync meta leader

This branch includes the following new commits:

     new 2a58d9d  remove unnecessary sync meta leader

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: remove unnecessary sync meta leader

Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2a58d9df58aad4513d1489625c19f56f02862dea
Author: LebronAl <TX...@gmail.com>
AuthorDate: Mon Mar 8 16:52:12 2021 +0800

    remove unnecessary sync meta leader
---
 .../src/main/java/org/apache/iotdb/cluster/ClusterMain.java    |  4 ++--
 .../apache/iotdb/cluster/query/ClusterDataQueryExecutor.java   |  8 ++++++++
 .../iotdb/cluster/query/reader/ClusterReaderFactory.java       | 10 ++++------
 .../iotdb/cluster/query/reader/ClusterTimeGenerator.java       |  4 +++-
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java b/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java
index 993a632..db84a86 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java
@@ -260,7 +260,7 @@ public class ClusterMain {
           @Override
           public int calculateSlotByTime(String storageGroupName, long timestamp, int maxSlotNum) {
             int sgSerialNum = extractSerialNumInSGName(storageGroupName) % k;
-            if (sgSerialNum > 0) {
+            if (sgSerialNum >= 0) {
               return maxSlotNum / k * sgSerialNum;
             } else {
               return defaultStrategy.calculateSlotByTime(storageGroupName, timestamp, maxSlotNum);
@@ -271,7 +271,7 @@ public class ClusterMain {
           public int calculateSlotByPartitionNum(
               String storageGroupName, long partitionId, int maxSlotNum) {
             int sgSerialNum = extractSerialNumInSGName(storageGroupName) % k;
-            if (sgSerialNum > 0) {
+            if (sgSerialNum >= 0) {
               return maxSlotNum / k * sgSerialNum;
             } else {
               return defaultStrategy.calculateSlotByPartitionNum(
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterDataQueryExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterDataQueryExecutor.java
index 621acf5..fbf8963 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterDataQueryExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterDataQueryExecutor.java
@@ -19,6 +19,7 @@
 
 package org.apache.iotdb.cluster.query;
 
+import org.apache.iotdb.cluster.exception.CheckConsistencyException;
 import org.apache.iotdb.cluster.exception.EmptyIntervalException;
 import org.apache.iotdb.cluster.query.reader.ClusterReaderFactory;
 import org.apache.iotdb.cluster.query.reader.ClusterTimeGenerator;
@@ -65,6 +66,13 @@ public class ClusterDataQueryExecutor extends RawDataQueryExecutor {
       timeFilter = ((GlobalTimeExpression) queryPlan.getExpression()).getFilter();
     }
 
+    // make sure the partition table is new
+    try {
+      metaGroupMember.syncLeaderWithConsistencyCheck(false);
+    } catch (CheckConsistencyException e) {
+      throw new StorageEngineException(e);
+    }
+
     List<ManagedSeriesReader> readersOfSelectedSeries = new ArrayList<>();
     for (int i = 0; i < queryPlan.getDeduplicatedPaths().size(); i++) {
       PartialPath path = queryPlan.getDeduplicatedPaths().get(i);
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
index 9b78175..562e8d3 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
@@ -85,6 +85,10 @@ public class ClusterReaderFactory {
     this.metaGroupMember = metaGroupMember;
   }
 
+  public void syncMetaGroup() throws CheckConsistencyException {
+    metaGroupMember.syncLeaderWithConsistencyCheck(false);
+  }
+
   /**
    * Create an IReaderByTimestamp that can read the data of "path" by timestamp in the whole
    * cluster. This will query every group and merge the result from them.
@@ -216,12 +220,6 @@ public class ClusterReaderFactory {
       QueryContext context,
       boolean ascending)
       throws StorageEngineException, EmptyIntervalException {
-    // make sure the partition table is new
-    try {
-      metaGroupMember.syncLeaderWithConsistencyCheck(false);
-    } catch (CheckConsistencyException e) {
-      throw new StorageEngineException(e);
-    }
     // find the groups that should be queried using the timeFilter
     List<PartitionGroup> partitionGroups = metaGroupMember.routeFilter(timeFilter, path);
     logger.debug(
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterTimeGenerator.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterTimeGenerator.java
index eaa1a2d..b7b5f51 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterTimeGenerator.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterTimeGenerator.java
@@ -19,6 +19,7 @@
 
 package org.apache.iotdb.cluster.query.reader;
 
+import org.apache.iotdb.cluster.exception.CheckConsistencyException;
 import org.apache.iotdb.cluster.metadata.CMManager;
 import org.apache.iotdb.cluster.server.member.MetaGroupMember;
 import org.apache.iotdb.db.exception.StorageEngineException;
@@ -51,8 +52,9 @@ public class ClusterTimeGenerator extends ServerTimeGenerator {
     this.queryPlan = rawDataQueryPlan;
     this.readerFactory = new ClusterReaderFactory(metaGroupMember);
     try {
+      readerFactory.syncMetaGroup();
       constructNode(expression);
-    } catch (IOException e) {
+    } catch (IOException | CheckConsistencyException e) {
       throw new StorageEngineException(e);
     }
   }