You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/06/24 02:52:19 UTC

[iotdb] 01/01: add statement step tracker

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

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

commit f99d72a0f7b3f2bf69e714a9dad3c32142792163
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Fri Jun 24 10:52:06 2022 +0800

    add statement step tracker
---
 .../org/apache/iotdb/db/mpp/plan/Coordinator.java  | 47 ++++++++++++----------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/Coordinator.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/Coordinator.java
index c8a44bdff1..e4d696ed3d 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/Coordinator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/Coordinator.java
@@ -109,28 +109,33 @@ public class Coordinator {
       String sql,
       IPartitionFetcher partitionFetcher,
       ISchemaFetcher schemaFetcher) {
-    QueryId globalQueryId = queryIdGenerator.createNextQueryId();
-    try (SetThreadName queryName = new SetThreadName(globalQueryId.getId())) {
-      if (sql != null && sql.length() > 0) {
-        LOGGER.info("start executing sql: {}", sql);
+    long startTime = System.nanoTime();
+    try {
+      QueryId globalQueryId = queryIdGenerator.createNextQueryId();
+      try (SetThreadName queryName = new SetThreadName(globalQueryId.getId())) {
+        if (sql != null && sql.length() > 0) {
+          LOGGER.info("start executing sql: {}", sql);
+        }
+        IQueryExecution execution =
+            createQueryExecution(
+                statement,
+                new MPPQueryContext(
+                    sql,
+                    globalQueryId,
+                    session,
+                    DataNodeEndPoints.LOCAL_HOST_DATA_BLOCK_ENDPOINT,
+                    DataNodeEndPoints.LOCAL_HOST_INTERNAL_ENDPOINT),
+                partitionFetcher,
+                schemaFetcher);
+        if (execution.isQuery()) {
+          queryExecutionMap.put(queryId, execution);
+        }
+        execution.start();
+
+        return execution.getStatus();
       }
-      IQueryExecution execution =
-          createQueryExecution(
-              statement,
-              new MPPQueryContext(
-                  sql,
-                  globalQueryId,
-                  session,
-                  DataNodeEndPoints.LOCAL_HOST_DATA_BLOCK_ENDPOINT,
-                  DataNodeEndPoints.LOCAL_HOST_INTERNAL_ENDPOINT),
-              partitionFetcher,
-              schemaFetcher);
-      if (execution.isQuery()) {
-        queryExecutionMap.put(queryId, execution);
-      }
-      execution.start();
-
-      return execution.getStatus();
+    } finally {
+      StepTracker.trace("statementExec", startTime, System.nanoTime());
     }
   }