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/03/17 13:07:37 UTC

[iotdb] branch performace_overview_dashboard updated: Fix SimpleSonsensus

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

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


The following commit(s) were added to refs/heads/performace_overview_dashboard by this push:
     new 7e9cd0f492 Fix SimpleSonsensus
7e9cd0f492 is described below

commit 7e9cd0f492d810d4bc6941d4376f1bf60eaa0fd3
Author: OneSizeFitQuorum <ta...@apache.org>
AuthorDate: Fri Mar 17 21:07:21 2023 +0800

    Fix SimpleSonsensus
    
    Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
 .../iotdb/consensus/simple/SimpleConsensus.java    | 26 +++++++++++++---------
 .../statemachine/DataRegionStateMachine.java       |  3 ++-
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java b/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java
index e5db5ba9fd..27a1687e90 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java
@@ -22,6 +22,7 @@ package org.apache.iotdb.consensus.simple;
 import org.apache.iotdb.common.rpc.thrift.TEndPoint;
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.consensus.ConsensusGroupId;
+import org.apache.iotdb.commons.consensus.DataRegionId;
 import org.apache.iotdb.commons.service.metric.MetricService;
 import org.apache.iotdb.commons.service.metric.enums.Metric;
 import org.apache.iotdb.commons.service.metric.enums.PerformanceOverviewMetrics;
@@ -127,16 +128,21 @@ class SimpleConsensus implements IConsensus {
       status = new TSStatus(TSStatusCode.SYSTEM_READ_ONLY.getStatusCode());
       status.setMessage("Fail to do non-query operations because system is read-only.");
     } else {
-      long startWriteTime = System.nanoTime();
-      status = impl.write(request);
-      MetricService.getInstance()
-          .timer(
-              System.nanoTime() - startWriteTime,
-              TimeUnit.NANOSECONDS,
-              Metric.PERFORMANCE_OVERVIEW_STORAGE_DETAIL.toString(),
-              MetricLevel.IMPORTANT,
-              Tag.STAGE.toString(),
-              PerformanceOverviewMetrics.ENGINE);
+      if (groupId instanceof DataRegionId) {
+        long startWriteTime = System.nanoTime();
+        status = impl.write(request);
+        // only record time cost for data region in Performance Overview Dashboard
+        MetricService.getInstance()
+            .timer(
+                System.nanoTime() - startWriteTime,
+                TimeUnit.NANOSECONDS,
+                Metric.PERFORMANCE_OVERVIEW_STORAGE_DETAIL.toString(),
+                MetricLevel.IMPORTANT,
+                Tag.STAGE.toString(),
+                PerformanceOverviewMetrics.ENGINE);
+      } else {
+        status = impl.write(request);
+      }
     }
     return ConsensusWriteResponse.newBuilder().setStatus(status).build();
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/DataRegionStateMachine.java b/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/DataRegionStateMachine.java
index 4ce6d3fd9d..41b54c50df 100644
--- a/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/DataRegionStateMachine.java
+++ b/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/DataRegionStateMachine.java
@@ -181,7 +181,8 @@ public class DataRegionStateMachine extends BaseStateMachine {
     }
 
     InsertNode result;
-    if (insertNodes.get(0) instanceof InsertTabletNode) { // merge to InsertMultiTabletsNode
+    // merge to InsertMultiTabletsNode
+    if (insertNodes.get(0) instanceof InsertTabletNode) {
       List<Integer> index = new ArrayList<>(size);
       List<InsertTabletNode> insertTabletNodes = new ArrayList<>(size);
       int i = 0;