You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2024/07/11 03:02:28 UTC
(iotdb) branch 1.3.1-queryDebug created (now e0469a9aba9)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a change to branch 1.3.1-queryDebug
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at e0469a9aba9 supprt debug
This branch includes the following new commits:
new e0469a9aba9 supprt debug
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: supprt debug
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch 1.3.1-queryDebug
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit e0469a9aba91ff5ddc0d88d6214d5cd0ac965f2c
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Thu Jul 11 11:02:12 2024 +0800
supprt debug
---
.mvn/.develocity/develocity-workspace-id | 1 +
.../main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 2 +-
.../execution/fragment/FragmentInstanceManager.java | 4 ++++
.../db/queryengine/execution/fragment/QueryContext.java | 4 ++++
.../apache/iotdb/db/queryengine/plan/analyze/Analysis.java | 11 +++++++++++
.../iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java | 2 +-
.../plan/planner/distribution/DistributionPlanner.java | 3 +++
.../db/queryengine/plan/planner/plan/FragmentInstance.java | 12 ++++++++++++
.../db/queryengine/plan/statement/crud/QueryStatement.java | 12 ++++++++++++
.../schemaengine/schemaregion/utils/ResourceByPathUtils.java | 11 +++++++++++
10 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/.mvn/.develocity/develocity-workspace-id b/.mvn/.develocity/develocity-workspace-id
new file mode 100644
index 00000000000..2e56ea31182
--- /dev/null
+++ b/.mvn/.develocity/develocity-workspace-id
@@ -0,0 +1 @@
+gfajylps6zb3jch4sxzzlwill4
\ No newline at end of file
diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index 56568d653da..3ae0facc74c 100644
--- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -658,7 +658,7 @@ selectStatement
// ---- Select Clause
selectClause
- : SELECT LAST? resultColumn (COMMA resultColumn)*
+ : DEBUG? SELECT LAST? resultColumn (COMMA resultColumn)*
;
resultColumn
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java
index f17d6d3926d..c43fded3664 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java
@@ -149,6 +149,8 @@ public class FragmentInstanceManager {
instance.getGlobalTimePredicate(),
dataNodeQueryContextMap));
+ context.setDebug(instance.isDebug());
+
try {
List<PipelineDriverFactory> driverFactories =
planner.plan(
@@ -231,6 +233,8 @@ public class FragmentInstanceManager {
createFragmentInstanceContext(
fragmentInstanceId, stateMachine, instance.getSessionInfo()));
+ context.setDebug(instance.isDebug());
+
try {
List<PipelineDriverFactory> driverFactories =
planner.plan(instance.getFragment().getPlanNodeTree(), context, schemaRegion);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/QueryContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/QueryContext.java
index a749aa1657c..cbf55625783 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/QueryContext.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/QueryContext.java
@@ -130,6 +130,10 @@ public class QueryContext {
return debug;
}
+ public void setDebug(boolean debug) {
+ this.debug = debug;
+ }
+
public long getQueryTimeLowerBound() {
return queryTimeLowerBound;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/Analysis.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/Analysis.java
index 81c27d885f4..9f89b4543d2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/Analysis.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/Analysis.java
@@ -290,10 +290,21 @@ public class Analysis {
private List<String> measurementList;
private List<IMeasurementSchema> measurementSchemaList;
+ private final boolean debug;
+
+ public Analysis(boolean debug) {
+ this.debug = debug;
+ }
+
public Analysis() {
+ this.debug = false;
this.finishQueryAfterAnalyze = false;
}
+ public boolean isDebug() {
+ return debug;
+ }
+
public List<TRegionReplicaSet> getPartitionInfo(PartialPath seriesPath, Filter timefilter) {
return dataPartition.getDataRegionReplicaSetWithTimeFilter(seriesPath.getDevice(), timefilter);
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java
index dfac79c0fc5..43a0c3977bd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java
@@ -235,7 +235,7 @@ public class AnalyzeVisitor extends StatementVisitor<Analysis, MPPQueryContext>
@Override
public Analysis visitQuery(QueryStatement queryStatement, MPPQueryContext context) {
- Analysis analysis = new Analysis();
+ Analysis analysis = new Analysis(queryStatement.isDebug());
analysis.setLastLevelUseWildcard(queryStatement.isLastLevelUseWildcard());
try {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java
index 755119b2607..edf7f4aa819 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java
@@ -213,6 +213,9 @@ public class DistributionPlanner {
// Only execute this step for READ operation
if (context.getQueryType() == QueryType.READ) {
setSinkForRootInstance(subPlan, fragmentInstances);
+ if (analysis.isDebug()) {
+ fragmentInstances.forEach(fragmentInstance -> fragmentInstance.setDebug(true));
+ }
}
return new DistributedQueryPlan(
logicalPlan.getContext(), subPlan, subPlan.getPlanFragmentList(), fragmentInstances);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/FragmentInstance.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/FragmentInstance.java
index ae83fd6623a..ce3d01ea28e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/FragmentInstance.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/FragmentInstance.java
@@ -79,6 +79,8 @@ public class FragmentInstance implements IConsensusRequest {
// We can add some more params for a specific FragmentInstance
// So that we can make different FragmentInstance owns different data range.
+ private boolean debug = false;
+
public FragmentInstance(
PlanFragment fragment,
FragmentInstanceId id,
@@ -217,6 +219,7 @@ public class FragmentInstance implements IConsensusRequest {
boolean hasHostDataNode = ReadWriteIOUtils.readBool(buffer);
fragmentInstance.hostDataNode =
hasHostDataNode ? ThriftCommonsSerDeUtils.deserializeTDataNodeLocation(buffer) : null;
+ fragmentInstance.debug = ReadWriteIOUtils.readBool(buffer);
return fragmentInstance;
}
@@ -240,6 +243,7 @@ public class FragmentInstance implements IConsensusRequest {
if (hostDataNode != null) {
ThriftCommonsSerDeUtils.serializeTDataNodeLocation(hostDataNode, outputStream);
}
+ ReadWriteIOUtils.write(debug, outputStream);
return ByteBuffer.wrap(publicBAOS.getBuf(), 0, publicBAOS.size());
} catch (IOException e) {
logger.error("Unexpected error occurs when serializing this FragmentInstance.", e);
@@ -247,6 +251,14 @@ public class FragmentInstance implements IConsensusRequest {
}
}
+ public boolean isDebug() {
+ return debug;
+ }
+
+ public void setDebug(boolean debug) {
+ this.debug = debug;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/QueryStatement.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/QueryStatement.java
index 80d3dec1a11..3d153cdc30a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/QueryStatement.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/QueryStatement.java
@@ -133,6 +133,8 @@ public class QueryStatement extends AuthorityInformationStatement {
// we can skip the query
private boolean isResultSetEmpty = false;
+ private boolean debug = false;
+
public QueryStatement() {
this.statementType = StatementType.QUERY;
}
@@ -820,4 +822,14 @@ public class QueryStatement extends AuthorityInformationStatement {
}
}
}
+
+ @Override
+ public boolean isDebug() {
+ return debug;
+ }
+
+ @Override
+ public void setDebug(boolean debug) {
+ this.debug = debug;
+ }
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
index d98cc819c91..5ed91fdd0c1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
@@ -51,6 +51,8 @@ import org.apache.iotdb.tsfile.utils.Pair;
import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
import org.apache.iotdb.tsfile.write.schema.VectorMeasurementSchema;
import org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.Serializable;
@@ -67,6 +69,9 @@ import static org.apache.iotdb.commons.path.AlignedPath.VECTOR_PLACEHOLDER;
*/
public abstract class ResourceByPathUtils {
+ public static final Logger DEBUG_LOGGER = LoggerFactory.getLogger("QUERY_DEBUG");
+
+
public static ResourceByPathUtils getResourceInstance(PartialPath path) {
if (path instanceof AlignedPath) {
return new AlignedResourceByPathUtils(path);
@@ -213,8 +218,14 @@ class AlignedResourceByPathUtils extends ResourceByPathUtils {
if (!containsMeasurement) {
return null;
}
+ if (context.isDebug()) {
+ DEBUG_LOGGER.info("TVList before sorting for Memtbale {} is {}", memTable.getMemTableId(), alignedMemChunk.getTVList());
+ }
// get sorted tv list is synchronized so different query can get right sorted list reference
TVList alignedTvListCopy = alignedMemChunk.getSortedTvListForQuery(partialPath.getSchemaList());
+ if (context.isDebug()) {
+ DEBUG_LOGGER.info("TVList after sorting for Memtbale {} is {}", memTable.getMemTableId(), alignedMemChunk.getTVList());
+ }
List<List<TimeRange>> deletionList = null;
if (modsToMemtable != null) {
deletionList = constructDeletionList(memTable, modsToMemtable, timeLowerBound);