This is an automated email from the ASF dual-hosted git repository. Wei-hao-Li pushed a commit to branch lwh/1.3-cp in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit aad83fbedd994fffa775292ac77b24477c4a6d6e Author: Weihao Li <[email protected]> AuthorDate: Tue Feb 10 17:36:19 2026 +0800 Support debug for query (#17178) (cherry picked from commit c052179dccf2fa3dc422626175f28372c86e9ba5) --- .../it/env/cluster/node/AbstractNodeWrapper.java | 19 ++++ .../it/query/recent/IoTDBDebugQueryIT.java | 105 +++++++++++++++++++++ .../assembly/resources/conf/logback-datanode.xml | 2 +- .../legacy/IoTDBLegacyPipeReceiverAgent.java | 1 + .../protocol/legacy/loader/DeletionLoader.java | 3 +- .../protocol/legacy/loader/TsFileLoader.java | 3 +- .../protocol/thrift/IoTDBDataNodeReceiver.java | 3 +- .../protocol/thrift/impl/ClientRPCServiceImpl.java | 25 +++-- .../impl/DataNodeInternalRPCServiceImpl.java | 1 + .../db/queryengine/common/MPPQueryContext.java | 10 ++ .../fragment/FakedFragmentInstanceContext.java | 2 +- .../fragment/FragmentInstanceContext.java | 47 ++++++--- .../fragment/FragmentInstanceManager.java | 8 +- .../execution/fragment/QueryContext.java | 10 +- .../iotdb/db/queryengine/plan/Coordinator.java | 100 +++++++++++++++----- .../analyze/schema/AutoCreateSchemaExecutor.java | 1 + .../analyze/schema/ClusterSchemaFetchExecutor.java | 3 +- .../plan/execution/IQueryExecution.java | 2 + .../queryengine/plan/execution/QueryExecution.java | 5 + .../plan/execution/config/ConfigExecution.java | 5 + .../config/executor/ClusterConfigTaskExecutor.java | 1 + .../SimpleFragmentParallelPlanner.java | 1 + .../distribution/WriteFragmentParallelPlanner.java | 3 +- .../plan/planner/plan/FragmentInstance.java | 29 +++++- .../plan/scheduler/load/LoadTsFileScheduler.java | 6 +- .../load/active/ActiveLoadTsFileLoader.java | 3 +- .../converter/LoadTsFileDataTypeConverter.java | 1 + .../execution/operator/MergeSortOperatorTest.java | 5 + .../plan/planner/FragmentInstanceSerdeTest.java | 6 +- .../memtable/MemChunkDeserializeTest.java | 4 +- .../dataregion/memtable/PrimitiveMemTableTest.java | 20 ++-- .../reader/chunk/MemAlignedChunkLoaderTest.java | 2 +- .../read/reader/chunk/MemChunkLoaderTest.java | 12 +-- .../wal/recover/file/TsFilePlanRedoerTest.java | 21 +++-- .../apache/iotdb/db/utils/EnvironmentUtils.java | 4 +- 35 files changed, 376 insertions(+), 97 deletions(-) diff --git a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java index 6c8f2717e71..afad120e94c 100644 --- a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java +++ b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java @@ -56,6 +56,7 @@ import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.nio.file.StandardOpenOption; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; @@ -764,4 +765,22 @@ public abstract class AbstractNodeWrapper implements BaseNodeWrapper { public Process getInstance() { return instance; } + + public int[] getPortList() { + return portList; + } + + public void clearLogContent() throws IOException { + Files.newOutputStream(Paths.get(getLogPath()), StandardOpenOption.TRUNCATE_EXISTING).close(); + } + + public boolean logContains(String content) throws IOException { + List<String> lines = Files.readAllLines(Paths.get(getLogPath()), StandardCharsets.UTF_8); + for (String line : lines) { + if (line.contains(content)) { + return true; + } + } + return false; + } } diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBDebugQueryIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBDebugQueryIT.java new file mode 100644 index 00000000000..d5702b29909 --- /dev/null +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBDebugQueryIT.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb.relational.it.query.recent; + +import org.apache.iotdb.it.env.EnvFactory; +import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper; +import org.apache.iotdb.it.framework.IoTDBTestRunner; +import org.apache.iotdb.itbase.category.TableLocalStandaloneIT; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import java.io.IOException; + +import static org.apache.iotdb.db.it.utils.TestUtils.prepareData; +import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData; +import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest; +import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest; +import static org.junit.Assert.assertTrue; + +@RunWith(IoTDBTestRunner.class) +@Category({TableLocalStandaloneIT.class}) +public class IoTDBDebugQueryIT { + private static final String DATABASE_NAME = "test_db"; + private static final String[] createTableSqls = + new String[] { + "CREATE DATABASE " + DATABASE_NAME, + "USE " + DATABASE_NAME, + "create table table1(device string tag, value int32 field)", + "insert into table1(time,device,value) values(2020-01-01 00:00:01.000,'d1',1)", + "FLUSH", + }; + private static final String[] createTreeSqls = + new String[] { + "create timeseries root.test.departments.department_id TEXT", + "create timeseries root.test.departments.dep_name TEXT", + "insert into root.test.departments(time, department_id, dep_name) values(1, 'D001', '研发部')", + "FLUSH", + }; + private static DataNodeWrapper dataNodeWrapper; + + @BeforeClass + public static void setUp() throws Exception { + EnvFactory.getEnv().initClusterEnvironment(); + dataNodeWrapper = EnvFactory.getEnv().getDataNodeWrapperList().get(0); + prepareTableData(createTableSqls); + prepareData(createTreeSqls); + } + + @AfterClass + public static void tearDown() throws Exception { + EnvFactory.getEnv().cleanClusterEnvironment(); + } + + @Test + public void tableTest() throws IOException { + // clear log content to reduce lines spanned in logContains check + dataNodeWrapper.clearLogContent(); + + String[] expectedHeader = new String[] {"time", "device", "value"}; + String[] retArray = new String[] {"2020-01-01T00:00:01.000Z,d1,1,"}; + String sql = "debug select time,device,value from table1"; + tableResultSetEqualTest(sql, expectedHeader, retArray, DATABASE_NAME); + + assertTrue(dataNodeWrapper.logContains("Cache miss: table1.d1")); + assertTrue(dataNodeWrapper.logContains(sql)); + } + + @Test + public void treeTest() throws IOException { + // clear log content to reduce lines spanned in logContains check + dataNodeWrapper.clearLogContent(); + + String[] expectedHeader = + new String[] { + "Time", "root.test.departments.department_id", "root.test.departments.dep_name" + }; + String[] retArray = new String[] {"1,D001,研发部,"}; + String sql = "debug select department_id, dep_name from root.test.departments"; + resultSetEqualTest(sql, expectedHeader, retArray); + + assertTrue(dataNodeWrapper.logContains("Cache miss: root.test.departments")); + assertTrue(dataNodeWrapper.logContains(sql)); + } +} diff --git a/iotdb-core/datanode/src/assembly/resources/conf/logback-datanode.xml b/iotdb-core/datanode/src/assembly/resources/conf/logback-datanode.xml index e827a7cbef2..a3a59d494ef 100644 --- a/iotdb-core/datanode/src/assembly/resources/conf/logback-datanode.xml +++ b/iotdb-core/datanode/src/assembly/resources/conf/logback-datanode.xml @@ -155,7 +155,7 @@ </rollingPolicy> <append>true</append> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> - <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern> + <pattern>%d [%t] %C{25}:%L - %m %n</pattern> <charset>utf-8</charset> </encoder> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java index ae7ab22308a..ba377036b55 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java @@ -156,6 +156,7 @@ public class IoTDBLegacyPipeReceiverAgent { partitionFetcher, schemaFetcher, IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(), + false, false); if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode() && result.status.code != TSStatusCode.DATABASE_ALREADY_EXISTS.getStatusCode() diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/DeletionLoader.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/DeletionLoader.java index 019dfb7718b..9c318347169 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/DeletionLoader.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/DeletionLoader.java @@ -69,7 +69,8 @@ public class DeletionLoader implements ILoader { PARTITION_FETCHER, SCHEMA_FETCHER, IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(), - false); + false, + statement.isDebug()); if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { LOGGER.error("Delete {} error, statement: {}.", deletion, statement); LOGGER.error("Delete result status : {}.", result.status); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/TsFileLoader.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/TsFileLoader.java index 8459e22f1ee..13f9c299177 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/TsFileLoader.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/TsFileLoader.java @@ -72,7 +72,8 @@ public class TsFileLoader implements ILoader { PARTITION_FETCHER, SCHEMA_FETCHER, IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(), - false); + false, + statement.isDebug()); if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { LOGGER.error("Load TsFile {} error, statement: {}.", tsFile.getPath(), statement); LOGGER.error("Load TsFile result status : {}.", result.status); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java index 58d4c29eddc..067810a1bf6 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java @@ -767,7 +767,8 @@ public class IoTDBDataNodeReceiver extends IoTDBFileReceiver { ClusterPartitionFetcher.getInstance(), ClusterSchemaFetcher.getInstance(), IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(), - false) + false, + statement.isDebug()) .status; } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java index 2ae50d36057..bb57d80f6d3 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java @@ -335,7 +335,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { partitionFetcher, schemaFetcher, req.getTimeout(), - true); + true, + s.isDebug()); } if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode() @@ -431,7 +432,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { partitionFetcher, schemaFetcher, req.getTimeout(), - true); + true, + s.isDebug()); if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { finished = true; @@ -522,7 +524,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { partitionFetcher, schemaFetcher, req.getTimeout(), - true); + true, + s.isDebug()); if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { finished = true; @@ -612,7 +615,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { partitionFetcher, schemaFetcher, req.getTimeout(), - true); + true, + s.isDebug()); if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { finished = true; @@ -1059,7 +1063,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { partitionFetcher, schemaFetcher, req.getTimeout(), - true); + true, + s.isDebug()); if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { finished = true; @@ -1659,7 +1664,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { partitionFetcher, schemaFetcher, config.getQueryTimeoutThreshold(), - false); + false, + s.isDebug()); } results.add(result.status); } catch (Exception e) { @@ -2515,7 +2521,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { partitionFetcher, schemaFetcher, config.getQueryTimeoutThreshold(), - true); + true, + statement.isDebug()); if (executionResult.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode() && executionResult.status.code != TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode()) { @@ -2910,6 +2917,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { ExecutionResult result = null; final List<? extends Statement> subStatements = statement.getSubStatements(); final int totalSubStatements = subStatements.size(); + boolean debug = statement.isDebug(); LOGGER.info( "Start batch executing {} sub-statement(s) in tree model, queryId: {}", @@ -2934,7 +2942,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler { partitionFetcher, schemaFetcher, timeoutMs, - userQuery); + userQuery, + debug); // Exit early if any sub-statement execution fails if (result != null diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index e265994a370..73be5d2800d 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -1517,6 +1517,7 @@ public class DataNodeInternalRPCServiceImpl implements IDataNodeRPCService.Iface partitionFetcher, schemaFetcher, req.getTimeout(), + false, false); if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode() diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java index 13773c15090..332837c4b6d 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java @@ -106,6 +106,8 @@ public class MPPQueryContext { */ private boolean needSetHighestPriority = false; + private boolean debug = false; + @TestOnly public MPPQueryContext(QueryId queryId) { this.queryId = queryId; @@ -412,6 +414,14 @@ public class MPPQueryContext { this.userQuery = userQuery; } + public boolean isDebug() { + return debug; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + public boolean needSetHighestPriority() { return needSetHighestPriority; } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FakedFragmentInstanceContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FakedFragmentInstanceContext.java index a76ca60fd5c..a2641b881b2 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FakedFragmentInstanceContext.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FakedFragmentInstanceContext.java @@ -35,7 +35,7 @@ import java.util.List; public class FakedFragmentInstanceContext extends FragmentInstanceContext { public FakedFragmentInstanceContext(Filter timeFilter, DataRegion dataRegion) { - super(0, new FakedMemoryReservationManager(), timeFilter, dataRegion); + super(0, new FakedMemoryReservationManager(), timeFilter, dataRegion, false); } public QueryDataSource getSharedQueryDataSource(PartialPath sourcePath) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java index a224e5b2c35..7ec557a7bb6 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java @@ -156,9 +156,12 @@ public class FragmentInstanceContext extends QueryContext { private boolean highestPriority = false; public static FragmentInstanceContext createFragmentInstanceContext( - FragmentInstanceId id, FragmentInstanceStateMachine stateMachine, SessionInfo sessionInfo) { + FragmentInstanceId id, + FragmentInstanceStateMachine stateMachine, + SessionInfo sessionInfo, + boolean debug) { FragmentInstanceContext instanceContext = - new FragmentInstanceContext(id, stateMachine, sessionInfo); + new FragmentInstanceContext(id, stateMachine, sessionInfo, debug); instanceContext.initialize(); instanceContext.start(); return instanceContext; @@ -169,9 +172,10 @@ public class FragmentInstanceContext extends QueryContext { FragmentInstanceStateMachine stateMachine, SessionInfo sessionInfo, IDataRegionForQuery dataRegion, - Filter timeFilter) { + Filter timeFilter, + boolean debug) { FragmentInstanceContext instanceContext = - new FragmentInstanceContext(id, stateMachine, sessionInfo, dataRegion, timeFilter); + new FragmentInstanceContext(id, stateMachine, sessionInfo, dataRegion, timeFilter, debug); instanceContext.initialize(); instanceContext.start(); return instanceContext; @@ -183,7 +187,8 @@ public class FragmentInstanceContext extends QueryContext { SessionInfo sessionInfo, IDataRegionForQuery dataRegion, TimePredicate globalTimePredicate, - Map<QueryId, DataNodeQueryContext> dataNodeQueryContextMap) { + Map<QueryId, DataNodeQueryContext> dataNodeQueryContextMap, + boolean debug) { FragmentInstanceContext instanceContext = new FragmentInstanceContext( id, @@ -191,14 +196,15 @@ public class FragmentInstanceContext extends QueryContext { sessionInfo, dataRegion, globalTimePredicate, - dataNodeQueryContextMap); + dataNodeQueryContextMap, + debug); instanceContext.initialize(); instanceContext.start(); return instanceContext; } public static FragmentInstanceContext createFragmentInstanceContextForCompaction(long queryId) { - return new FragmentInstanceContext(queryId, null, null, null); + return new FragmentInstanceContext(queryId, null, null, null, false); } public void setQueryDataSourceType(QueryDataSourceType queryDataSourceType) { @@ -210,7 +216,7 @@ public class FragmentInstanceContext extends QueryContext { FragmentInstanceId id, FragmentInstanceStateMachine stateMachine) { FragmentInstanceContext instanceContext = new FragmentInstanceContext( - id, stateMachine, new SessionInfo(1, "test", ZoneId.systemDefault(), "")); + id, stateMachine, new SessionInfo(1, "test", ZoneId.systemDefault(), ""), false); instanceContext.initialize(); instanceContext.start(); return instanceContext; @@ -226,7 +232,8 @@ public class FragmentInstanceContext extends QueryContext { id, stateMachine, new SessionInfo(1, "test", ZoneId.systemDefault(), ""), - memoryReservationManager); + memoryReservationManager, + false); instanceContext.initialize(); instanceContext.start(); return instanceContext; @@ -238,7 +245,9 @@ public class FragmentInstanceContext extends QueryContext { SessionInfo sessionInfo, IDataRegionForQuery dataRegion, TimePredicate globalTimePredicate, - Map<QueryId, DataNodeQueryContext> dataNodeQueryContextMap) { + Map<QueryId, DataNodeQueryContext> dataNodeQueryContextMap, + boolean debug) { + super(debug); this.id = id; this.stateMachine = stateMachine; this.executionEndTime.set(END_TIME_INITIAL_VALUE); @@ -253,7 +262,11 @@ public class FragmentInstanceContext extends QueryContext { } private FragmentInstanceContext( - FragmentInstanceId id, FragmentInstanceStateMachine stateMachine, SessionInfo sessionInfo) { + FragmentInstanceId id, + FragmentInstanceStateMachine stateMachine, + SessionInfo sessionInfo, + boolean debug) { + super(debug); this.id = id; this.stateMachine = stateMachine; this.executionEndTime.set(END_TIME_INITIAL_VALUE); @@ -268,7 +281,9 @@ public class FragmentInstanceContext extends QueryContext { FragmentInstanceId id, FragmentInstanceStateMachine stateMachine, SessionInfo sessionInfo, - MemoryReservationManager memoryReservationManager) { + MemoryReservationManager memoryReservationManager, + boolean debug) { + super(debug); this.id = id; this.stateMachine = stateMachine; this.executionEndTime.set(END_TIME_INITIAL_VALUE); @@ -283,7 +298,9 @@ public class FragmentInstanceContext extends QueryContext { FragmentInstanceStateMachine stateMachine, SessionInfo sessionInfo, IDataRegionForQuery dataRegion, - Filter globalTimeFilter) { + Filter globalTimeFilter, + boolean debug) { + super(debug); this.id = id; this.stateMachine = stateMachine; this.executionEndTime.set(END_TIME_INITIAL_VALUE); @@ -305,7 +322,9 @@ public class FragmentInstanceContext extends QueryContext { long queryId, MemoryReservationManager memoryReservationManager, Filter timeFilter, - DataRegion dataRegion) { + DataRegion dataRegion, + boolean debug) { + super(debug); this.queryId = queryId; this.id = null; this.stateMachine = null; 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 9dacdf44d88..93b562444bf 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 @@ -157,7 +157,8 @@ public class FragmentInstanceManager { instance.getSessionInfo(), dataRegion, instance.getGlobalTimePredicate(), - dataNodeQueryContextMap)); + dataNodeQueryContextMap, + instance.isDebug())); context.setHighestPriority(instance.isHighestPriority()); try { @@ -259,7 +260,10 @@ public class FragmentInstanceManager { instanceId, fragmentInstanceId -> createFragmentInstanceContext( - fragmentInstanceId, stateMachine, instance.getSessionInfo())); + fragmentInstanceId, + stateMachine, + instance.getSessionInfo(), + instance.isDebug())); context.setHighestPriority(instance.isHighestPriority()); try { 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 d1b235ff7b1..b0022ddb26a 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 @@ -60,7 +60,7 @@ public class QueryContext { protected long queryId; - private boolean debug; + private final boolean debug; private long startTime; private long timeout; @@ -72,10 +72,12 @@ public class QueryContext { // referenced TVLists for the query protected final Set<TVList> tvListSet = new HashSet<>(); - public QueryContext() {} + public QueryContext(boolean debug) { + this.debug = debug; + } - public QueryContext(long queryId) { - this(queryId, false, System.currentTimeMillis(), 0); + public QueryContext(long queryId, boolean debug) { + this(queryId, debug, System.currentTimeMillis(), 0); } /** Every time we generate the queryContext, register it to queryTimeManager. */ diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java index 2f173861f22..29e6dc07b87 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java @@ -60,6 +60,8 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadPoolExecutor; import java.util.function.BiFunction; +import java.util.function.LongSupplier; +import java.util.function.Supplier; import static org.apache.iotdb.commons.utils.StatusUtils.needRetry; import static org.apache.iotdb.db.utils.CommonUtils.getContentOfRequest; @@ -82,6 +84,8 @@ public class Coordinator { private static final Logger SAMPLED_QUERIES_LOGGER = LoggerFactory.getLogger(IoTDBConstant.SAMPLED_QUERIES_LOGGER_NAME); + private static final Logger DEBUG_LOGGER = LoggerFactory.getLogger("QUERY_DEBUG"); + private static final IClientManager<TEndPoint, SyncDataNodeInternalServiceClient> SYNC_INTERNAL_SERVICE_CLIENT_MANAGER = new IClientManager.Factory<TEndPoint, SyncDataNodeInternalServiceClient>() @@ -124,6 +128,7 @@ public class Coordinator { SessionInfo session, String sql, boolean userQuery, + boolean debug, BiFunction<MPPQueryContext, Long, IQueryExecution> iQueryExecutionFactory) { long startTime = System.currentTimeMillis(); QueryId globalQueryId = queryIdGenerator.createNextQueryId(); @@ -141,6 +146,7 @@ public class Coordinator { DataNodeEndPoints.LOCAL_HOST_DATA_BLOCK_ENDPOINT, DataNodeEndPoints.LOCAL_HOST_INTERNAL_ENDPOINT); queryContext.setUserQuery(userQuery); + queryContext.setDebug(debug); IQueryExecution execution = iQueryExecutionFactory.apply(queryContext, startTime); if (execution.isQuery()) { queryExecutionMap.put(queryId, execution); @@ -172,7 +178,15 @@ public class Coordinator { IPartitionFetcher partitionFetcher, ISchemaFetcher schemaFetcher) { return executeForTreeModel( - statement, queryId, session, sql, partitionFetcher, schemaFetcher, Long.MAX_VALUE, false); + statement, + queryId, + session, + sql, + partitionFetcher, + schemaFetcher, + Long.MAX_VALUE, + false, + statement.isDebug()); } public ExecutionResult executeForTreeModel( @@ -183,12 +197,14 @@ public class Coordinator { IPartitionFetcher partitionFetcher, ISchemaFetcher schemaFetcher, long timeOut, - boolean userQuery) { + boolean userQuery, + boolean debug) { return execution( queryId, session, sql, userQuery, + debug, ((queryContext, startTime) -> createQueryExecutionForTreeModel( statement, @@ -227,6 +243,29 @@ public class Coordinator { return new QueryExecution(treeModelPlanner, queryContext, executor); } + /** For compatibility of MQTT and REST, this method should never be called. */ + @Deprecated + public ExecutionResult executeForTreeModel( + Statement statement, + long queryId, + SessionInfo sessionInfo, + String s, + IPartitionFetcher partitionFetcher, + ISchemaFetcher schemaFetcher, + long queryTimeoutThreshold, + boolean isUserQuery) { + return executeForTreeModel( + statement, + queryId, + sessionInfo, + s, + partitionFetcher, + schemaFetcher, + queryTimeoutThreshold, + isUserQuery, + false); + } + public IQueryExecution getQueryExecution(Long queryId) { return queryExecutionMap.get(queryId); } @@ -263,27 +302,11 @@ public class Coordinator { LOGGER.debug("[CleanUpQuery]]"); queryExecution.stopAndCleanup(t); if (queryExecution.isQuery() && queryExecution.isUserQuery()) { - long costTime = queryExecution.getTotalExecutionTime(); - // print slow query - if (costTime / 1_000_000 >= CONFIG.getSlowQueryThreshold()) { - SLOW_SQL_LOGGER.info( - "Cost: {} ms, {}", - costTime / 1_000_000, - getContentOfRequest(nativeApiRequest, queryExecution)); - } - - // only sample successful query - if (t == null && COMMON_CONFIG.isEnableQuerySampling()) { // sampling is enabled - String queryRequest = getContentOfRequest(nativeApiRequest, queryExecution); - if (COMMON_CONFIG.isQuerySamplingHasRateLimit()) { - if (COMMON_CONFIG.getQuerySamplingRateLimiter().tryAcquire(queryRequest.length())) { - SAMPLED_QUERIES_LOGGER.info(queryRequest); - } - } else { - // no limit, always sampled - SAMPLED_QUERIES_LOGGER.info(queryRequest); - } - } + recordQueries( + queryExecution::getTotalExecutionTime, + () -> getContentOfRequest(nativeApiRequest, queryExecution), + t, + queryExecution.isDebug()); } } } @@ -318,6 +341,37 @@ public class Coordinator { }); } + public static void recordQueries( + LongSupplier executionTime, + Supplier<String> contentOfQuerySupplier, + Throwable t, + boolean debug) { + + long costTime = executionTime.getAsLong(); + // print slow query + if (costTime / 1_000_000 >= CONFIG.getSlowQueryThreshold()) { + SLOW_SQL_LOGGER.info("Cost: {} ms, {}", costTime / 1_000_000, contentOfQuerySupplier.get()); + } + + // always print the query when debug is true + if (debug) { + DEBUG_LOGGER.info(contentOfQuerySupplier.get()); + } + + // only sample successful query + if (t == null && COMMON_CONFIG.isEnableQuerySampling()) { // sampling is enabled + String queryRequest = contentOfQuerySupplier.get(); + if (COMMON_CONFIG.isQuerySamplingHasRateLimit()) { + if (COMMON_CONFIG.getQuerySamplingRateLimiter().tryAcquire(queryRequest.length())) { + SAMPLED_QUERIES_LOGGER.info(queryRequest); + } + } else { + // no limit, always sampled + SAMPLED_QUERIES_LOGGER.info(queryRequest); + } + } + } + public void cleanupQueryExecution(Long queryId) { cleanupQueryExecution(queryId, null, null); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java index e7fa45be64a..583afac0e63 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java @@ -95,6 +95,7 @@ class AutoCreateSchemaExecutor { context == null || context.getQueryType().equals(QueryType.WRITE) ? config.getQueryTimeoutThreshold() : context.getTimeOut(), + false, false); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java index 7a30a6fa50f..84db7e7cb03 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java @@ -94,7 +94,8 @@ class ClusterSchemaFetchExecutor { ClusterPartitionFetcher.getInstance(), schemaFetcher, timeout, - false); + false, + statement.isDebug()); } /** diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/IQueryExecution.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/IQueryExecution.java index 09f25a781e1..d41db48afec 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/IQueryExecution.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/IQueryExecution.java @@ -95,4 +95,6 @@ public interface IQueryExecution { Optional<String> getExecuteSQL(); String getStatementType(); + + boolean isDebug(); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java index 5af143bfca8..abc38479705 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java @@ -708,6 +708,11 @@ public class QueryExecution implements IQueryExecution { return analysis.getStatementType(); } + @Override + public boolean isDebug() { + return context.isDebug(); + } + public MPPQueryContext getContext() { return context; } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java index e3cf2408f06..86bb3b0ad2d 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java @@ -285,4 +285,9 @@ public class ConfigExecution implements IQueryExecution { public String getStatementType() { return statementType.name(); } + + @Override + public boolean isDebug() { + return context.isDebug(); + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java index d582832864a..9b30d069fdb 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java @@ -2520,6 +2520,7 @@ public class ClusterConfigTaskExecutor implements IConfigTaskExecutor { ClusterPartitionFetcher.getInstance(), ClusterSchemaFetcher.getInstance(), IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(), + false, false); if (executionResult.status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { future.setException( diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/SimpleFragmentParallelPlanner.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/SimpleFragmentParallelPlanner.java index e0a193b63f1..37795a11378 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/SimpleFragmentParallelPlanner.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/SimpleFragmentParallelPlanner.java @@ -151,6 +151,7 @@ public class SimpleFragmentParallelPlanner implements IFragmentParallelPlaner { queryContext.getTimeOut(), queryContext.getSession(), queryContext.isExplainAnalyze(), + queryContext.isDebug(), fragment.isRoot()); // Get the target region for origin PlanFragment, then its instance will be distributed one diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/WriteFragmentParallelPlanner.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/WriteFragmentParallelPlanner.java index 9bc526ee4f5..3d707d552a3 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/WriteFragmentParallelPlanner.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/WriteFragmentParallelPlanner.java @@ -63,7 +63,8 @@ public class WriteFragmentParallelPlanner implements IFragmentParallelPlaner { analysis.getCovertedTimePredicate(), queryContext.getQueryType(), queryContext.getTimeOut(), - queryContext.getSession()); + queryContext.getSession(), + queryContext.isDebug()); if (split.getRegionReplicaSet() != null) { instance.setExecutorAndHost(new StorageExecutor(split.getRegionReplicaSet())); } 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 b96485199ad..f8dc760f687 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 need to cache and calculate the statistics of this FragmentInstance if it is. private boolean isExplainAnalyze = false; + private final boolean debug; + // We can add some more params for a specific FragmentInstance // So that we can make different FragmentInstance owns different data range. @@ -88,7 +90,8 @@ public class FragmentInstance implements IConsensusRequest { TimePredicate globalTimePredicate, QueryType type, long timeOut, - SessionInfo sessionInfo) { + SessionInfo sessionInfo, + boolean debug) { this.fragment = fragment; this.globalTimePredicate = globalTimePredicate; this.id = id; @@ -96,6 +99,7 @@ public class FragmentInstance implements IConsensusRequest { this.timeOut = timeOut > 0 ? timeOut : CONFIG.getQueryTimeoutThreshold(); this.isRoot = false; this.sessionInfo = sessionInfo; + this.debug = debug; } public FragmentInstance( @@ -106,8 +110,9 @@ public class FragmentInstance implements IConsensusRequest { long timeOut, SessionInfo sessionInfo, boolean isExplainAnalyze, + boolean debug, boolean isRoot) { - this(fragment, id, globalTimePredicate, type, timeOut, sessionInfo); + this(fragment, id, globalTimePredicate, type, timeOut, sessionInfo, debug); this.isRoot = isRoot; this.isExplainAnalyze = isExplainAnalyze; } @@ -119,8 +124,9 @@ public class FragmentInstance implements IConsensusRequest { QueryType type, long timeOut, SessionInfo sessionInfo, - int dataNodeFINum) { - this(fragment, id, globalTimePredicate, type, timeOut, sessionInfo); + int dataNodeFINum, + boolean debug) { + this(fragment, id, globalTimePredicate, type, timeOut, sessionInfo, debug); this.dataNodeFINum = dataNodeFINum; } @@ -187,6 +193,10 @@ public class FragmentInstance implements IConsensusRequest { this.dataNodeFINum = dataNodeFINum; } + public boolean isDebug() { + return debug; + } + public String toString() { StringBuilder ret = new StringBuilder(); ret.append(String.format("FragmentInstance-%s:", getId())); @@ -216,9 +226,17 @@ public class FragmentInstance implements IConsensusRequest { TimePredicate globalTimePredicate = hasTimePredicate ? TimePredicate.deserialize(buffer) : null; QueryType queryType = QueryType.values()[ReadWriteIOUtils.readInt(buffer)]; int dataNodeFINum = ReadWriteIOUtils.readInt(buffer); + boolean debug = ReadWriteIOUtils.readBool(buffer); FragmentInstance fragmentInstance = new FragmentInstance( - planFragment, id, globalTimePredicate, queryType, timeOut, sessionInfo, dataNodeFINum); + planFragment, + id, + globalTimePredicate, + queryType, + timeOut, + sessionInfo, + dataNodeFINum, + debug); boolean hasHostDataNode = ReadWriteIOUtils.readBool(buffer); fragmentInstance.hostDataNode = hasHostDataNode ? ThriftCommonsSerDeUtils.deserializeTDataNodeLocation(buffer) : null; @@ -243,6 +261,7 @@ public class FragmentInstance implements IConsensusRequest { } ReadWriteIOUtils.write(type.ordinal(), outputStream); ReadWriteIOUtils.write(dataNodeFINum, outputStream); + ReadWriteIOUtils.write(debug, outputStream); ReadWriteIOUtils.write(hostDataNode != null, outputStream); if (hostDataNode != null) { ThriftCommonsSerDeUtils.serializeTDataNodeLocation(hostDataNode, outputStream); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java index 5cafe3b8384..7dd2a5d551a 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java @@ -339,7 +339,8 @@ public class LoadTsFileScheduler implements IScheduler { null, queryContext.getQueryType(), queryContext.getTimeOut(), - queryContext.getSession()); + queryContext.getSession(), + queryContext.isDebug()); instance.setExecutorAndHost(new StorageExecutor(replicaSet)); Future<FragInstanceDispatchResult> dispatchResultFuture = dispatcher.dispatch(null, Collections.singletonList(instance)); @@ -473,7 +474,8 @@ public class LoadTsFileScheduler implements IScheduler { null, queryContext.getQueryType(), queryContext.getTimeOut(), - queryContext.getSession()); + queryContext.getSession(), + queryContext.isDebug()); instance.setExecutorAndHost(new StorageExecutor(node.getLocalRegionReplicaSet())); dispatcher.dispatchLocally(instance); } catch (FragmentInstanceDispatchException e) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java index a228ef6c651..f20f7c0ed48 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java @@ -248,7 +248,8 @@ public class ActiveLoadTsFileLoader { ClusterPartitionFetcher.getInstance(), ClusterSchemaFetcher.getInstance(), IOTDB_CONFIG.getQueryTimeoutThreshold(), - false) + false, + statement.isDebug()) .status; } finally { SESSION_MANAGER.removeCurrSession(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTsFileDataTypeConverter.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTsFileDataTypeConverter.java index e46e25c5f7f..ad7e79e8f2c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTsFileDataTypeConverter.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTsFileDataTypeConverter.java @@ -109,6 +109,7 @@ public class LoadTsFileDataTypeConverter { ClusterPartitionFetcher.getInstance(), ClusterSchemaFetcher.getInstance(), IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(), + false, false) .status; } finally { diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/MergeSortOperatorTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/MergeSortOperatorTest.java index 76ec370ad98..25137cee4d7 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/MergeSortOperatorTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/MergeSortOperatorTest.java @@ -1882,5 +1882,10 @@ public class MergeSortOperatorTest { public boolean isUserQuery() { return false; } + + @Override + public boolean isDebug() { + return false; + } } } diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/FragmentInstanceSerdeTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/FragmentInstanceSerdeTest.java index e435468f533..3ee4cb56fe4 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/FragmentInstanceSerdeTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/FragmentInstanceSerdeTest.java @@ -77,7 +77,8 @@ public class FragmentInstanceSerdeTest { new TreeModelTimePredicate(ExpressionFactory.groupByTime(1, 2, 3, 4)), QueryType.READ, config.getQueryTimeoutThreshold(), - sessionInfo); + sessionInfo, + false); // test FI with StorageExecutor TRegionReplicaSet regionReplicaSet = new TRegionReplicaSet( @@ -119,7 +120,8 @@ public class FragmentInstanceSerdeTest { null, QueryType.READ, config.getQueryTimeoutThreshold(), - sessionInfo); + sessionInfo, + false); TRegionReplicaSet regionReplicaSet = new TRegionReplicaSet( new TConsensusGroupId(TConsensusGroupType.DataRegion, 1), diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/MemChunkDeserializeTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/MemChunkDeserializeTest.java index 04a81ee1866..4ac89010d31 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/MemChunkDeserializeTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/MemChunkDeserializeTest.java @@ -302,7 +302,7 @@ public class MemChunkDeserializeTest { memTableMap.put(deviceID, memChunkGroup); IMemTable memTable = new PrimitiveMemTable(storageGroup, dataRegionId, memTableMap); - QueryContext context = new QueryContext(); + QueryContext context = new QueryContext(false); MeasurementPath nonAlignedFullPath = new MeasurementPath( deviceID, @@ -327,7 +327,7 @@ public class MemChunkDeserializeTest { memTableMap.put(deviceID, memChunkGroup); IMemTable memTable = new PrimitiveMemTable(storageGroup, dataRegionId, memTableMap); - QueryContext context = new QueryContext(); + QueryContext context = new QueryContext(false); AlignedPath alignedFullPath = new AlignedPath("d1", measurementList, schemaList); return memTable.query(context, alignedFullPath, Long.MIN_VALUE, null, null); } diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/PrimitiveMemTableTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/PrimitiveMemTableTest.java index b9259db0a0f..34f0fa6ba43 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/PrimitiveMemTableTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/PrimitiveMemTableTest.java @@ -117,7 +117,7 @@ public class PrimitiveMemTableTest { tvListQueryMap.put(series.getWorkingTVList(), series.getWorkingTVList().rowCount()); ReadOnlyMemChunk readableChunk = new ReadOnlyMemChunk( - new QueryContext(), "s1", dataType, TSEncoding.PLAIN, tvListQueryMap, null, null); + new QueryContext(false), "s1", dataType, TSEncoding.PLAIN, tvListQueryMap, null, null); IPointReader it = readableChunk.getPointReader(); int i = 0; while (it.hasNextTimeValuePair()) { @@ -162,7 +162,7 @@ public class PrimitiveMemTableTest { new AlignedPath("root.test.d1", Arrays.asList("s1", "s2", "s3"), measurementSchemas)); ReadOnlyMemChunk readOnlyMemChunk = resourcesByPathUtils.getReadOnlyMemChunkFromMemTable( - new QueryContext(1), memTable, null, Long.MAX_VALUE, null); + new QueryContext(1, false), memTable, null, Long.MAX_VALUE, null); for (int i = 1; i <= 50; i++) { memTable.writeAlignedRow( @@ -206,7 +206,7 @@ public class PrimitiveMemTableTest { new AlignedPath("root.test.d1", Arrays.asList("s1", "s2", "s3"), measurementSchemas)); ReadOnlyMemChunk readOnlyMemChunk = resourcesByPathUtils.getReadOnlyMemChunkFromMemTable( - new QueryContext(), memTable, null, Long.MAX_VALUE, null); + new QueryContext(false), memTable, null, Long.MAX_VALUE, null); for (int i = 1; i <= 50; i++) { memTable.writeAlignedRow( @@ -343,7 +343,7 @@ public class PrimitiveMemTableTest { CompressionType.UNCOMPRESSED, Collections.emptyMap())); ReadOnlyMemChunk memChunk = - memTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + memTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); IPointReader iterator = memChunk.getPointReader(); for (int i = 0; i < dataSize; i++) { iterator.hasNextTimeValuePair(); @@ -445,7 +445,7 @@ public class PrimitiveMemTableTest { new Deletion(new PartialPath(deviceId, measurementId[0]), Long.MAX_VALUE, 10, dataSize); modsToMemtable.add(new Pair<>(deletion, memTable)); ReadOnlyMemChunk memChunk = - memTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, modsToMemtable, null); + memTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, modsToMemtable, null); IPointReader iterator = memChunk.getPointReader(); int cnt = 0; while (iterator.hasNextTimeValuePair()) { @@ -501,7 +501,7 @@ public class PrimitiveMemTableTest { new Deletion(new PartialPath(deviceId, measurementId[0]), Long.MAX_VALUE, 10, dataSize); modsToMemtable.add(new Pair<>(deletion, memTable)); ReadOnlyMemChunk memChunk = - memTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, modsToMemtable, null); + memTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, modsToMemtable, null); IPointReader iterator = memChunk.getPointReader(); int cnt = 0; while (iterator.hasNextTimeValuePair()) { @@ -541,7 +541,9 @@ public class PrimitiveMemTableTest { CompressionType.UNCOMPRESSED, Collections.emptyMap())); IPointReader tvPair = - memTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null).getPointReader(); + memTable + .query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null) + .getPointReader(); Arrays.sort(ret); TimeValuePair last = null; for (int i = 0; i < ret.length; i++) { @@ -587,7 +589,7 @@ public class PrimitiveMemTableTest { CompressionType.UNCOMPRESSED, Collections.emptyMap()))); IPointReader tvPair = - memTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null).getPointReader(); + memTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null).getPointReader(); for (int i = 0; i < 100; i++) { tvPair.hasNextTimeValuePair(); TimeValuePair next = tvPair.nextTimeValuePair(); @@ -614,7 +616,7 @@ public class PrimitiveMemTableTest { Collections.emptyMap()))); tvPair = - memTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null).getPointReader(); + memTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null).getPointReader(); for (int i = 0; i < 100; i++) { tvPair.hasNextTimeValuePair(); TimeValuePair next = tvPair.nextTimeValuePair(); diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedChunkLoaderTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedChunkLoaderTest.java index 87c6e28ea55..02a3fc90e38 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedChunkLoaderTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedChunkLoaderTest.java @@ -63,7 +63,7 @@ public class MemAlignedChunkLoaderTest { public void testMemAlignedChunkLoader() throws IOException { AlignedReadOnlyMemChunk chunk = Mockito.mock(AlignedReadOnlyMemChunk.class); ChunkMetadata chunkMetadata = Mockito.mock(ChunkMetadata.class); - QueryContext ctx = new QueryContext(); + QueryContext ctx = new QueryContext(false); MemAlignedChunkLoader memAlignedChunkLoader = new MemAlignedChunkLoader(ctx, chunk); try { diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemChunkLoaderTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemChunkLoaderTest.java index e852c656253..c8102c8eb59 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemChunkLoaderTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemChunkLoaderTest.java @@ -75,7 +75,7 @@ public class MemChunkLoaderTest { Mockito.when(chunk.getMemPointIterator()).thenReturn(timeValuePairIterator); ChunkMetadata chunkMetadata = Mockito.mock(ChunkMetadata.class); - MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(), chunk); + MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(false), chunk); try { memChunkLoader.loadChunk(chunkMetadata); fail(); @@ -154,7 +154,7 @@ public class MemChunkLoaderTest { Mockito.when(chunk.getMemPointIterator()).thenReturn(timeValuePairIterator); ChunkMetadata chunkMetadata = Mockito.mock(ChunkMetadata.class); - MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(), chunk); + MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(false), chunk); try { memChunkLoader.loadChunk(chunkMetadata); fail(); @@ -234,7 +234,7 @@ public class MemChunkLoaderTest { Mockito.when(chunk.getMemPointIterator()).thenReturn(timeValuePairIterator); ChunkMetadata chunkMetadata = Mockito.mock(ChunkMetadata.class); - MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(), chunk); + MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(false), chunk); try { memChunkLoader.loadChunk(chunkMetadata); fail(); @@ -314,7 +314,7 @@ public class MemChunkLoaderTest { Mockito.when(chunk.getMemPointIterator()).thenReturn(timeValuePairIterator); ChunkMetadata chunkMetadata = Mockito.mock(ChunkMetadata.class); - MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(), chunk); + MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(false), chunk); try { memChunkLoader.loadChunk(chunkMetadata); fail(); @@ -394,7 +394,7 @@ public class MemChunkLoaderTest { Mockito.when(chunk.getMemPointIterator()).thenReturn(timeValuePairIterator); ChunkMetadata chunkMetadata = Mockito.mock(ChunkMetadata.class); - MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(), chunk); + MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(false), chunk); try { memChunkLoader.loadChunk(chunkMetadata); fail(); @@ -474,7 +474,7 @@ public class MemChunkLoaderTest { Mockito.when(chunk.getMemPointIterator()).thenReturn(timeValuePairIterator); ChunkMetadata chunkMetadata = Mockito.mock(ChunkMetadata.class); - MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(), chunk); + MemChunkLoader memChunkLoader = new MemChunkLoader(new QueryContext(false), chunk); try { memChunkLoader.loadChunk(chunkMetadata); fail(); diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/wal/recover/file/TsFilePlanRedoerTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/wal/recover/file/TsFilePlanRedoerTest.java index fae5ee647a8..acbaaae6620 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/wal/recover/file/TsFilePlanRedoerTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/wal/recover/file/TsFilePlanRedoerTest.java @@ -156,7 +156,7 @@ public class TsFilePlanRedoerTest { new MeasurementPath( DEVICE2_NAME, "s1", new MeasurementSchema("s1", TSDataType.FLOAT, TSEncoding.RLE)); ReadOnlyMemChunk memChunk = - recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); IPointReader iterator = memChunk.getPointReader(); time = 5; while (iterator.hasNextTimeValuePair()) { @@ -170,7 +170,8 @@ public class TsFilePlanRedoerTest { fullPath = new MeasurementPath( DEVICE2_NAME, "s2", new MeasurementSchema("s2", TSDataType.DOUBLE, TSEncoding.RLE)); - memChunk = recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + memChunk = + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); iterator = memChunk.getPointReader(); time = 5; while (iterator.hasNextTimeValuePair()) { @@ -256,7 +257,7 @@ public class TsFilePlanRedoerTest { new MeasurementSchema("s4", TSDataType.FLOAT, TSEncoding.RLE), new MeasurementSchema("s5", TSDataType.TEXT, TSEncoding.PLAIN))); ReadOnlyMemChunk memChunk = - recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); IPointReader iterator = memChunk.getPointReader(); int time = 6; while (iterator.hasNextTimeValuePair()) { @@ -336,7 +337,7 @@ public class TsFilePlanRedoerTest { new MeasurementPath( DEVICE1_NAME, "s1", new MeasurementSchema("s1", TSDataType.INT32, TSEncoding.RLE)); ReadOnlyMemChunk memChunk = - recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); IPointReader iterator = memChunk.getPointReader(); int time = 5; while (iterator.hasNextTimeValuePair()) { @@ -350,7 +351,8 @@ public class TsFilePlanRedoerTest { fullPath = new MeasurementPath( DEVICE1_NAME, "s2", new MeasurementSchema("s2", TSDataType.INT64, TSEncoding.RLE)); - memChunk = recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + memChunk = + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); iterator = memChunk.getPointReader(); time = 5; while (iterator.hasNextTimeValuePair()) { @@ -449,7 +451,7 @@ public class TsFilePlanRedoerTest { new MeasurementSchema("s4", TSDataType.FLOAT, TSEncoding.RLE), new MeasurementSchema("s5", TSDataType.TEXT, TSEncoding.PLAIN))); ReadOnlyMemChunk memChunk = - recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); IPointReader iterator = memChunk.getPointReader(); int time = 6; while (iterator.hasNextTimeValuePair()) { @@ -571,13 +573,14 @@ public class TsFilePlanRedoerTest { new MeasurementPath( DEVICE1_NAME, "s1", new MeasurementSchema("s1", TSDataType.INT32, TSEncoding.RLE)); ReadOnlyMemChunk memChunk = - recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); assertTrue(memChunk == null || memChunk.isEmpty()); // check d1.s2 fullPath = new MeasurementPath( DEVICE1_NAME, "s2", new MeasurementSchema("s2", TSDataType.INT64, TSEncoding.RLE)); - memChunk = recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + memChunk = + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); assertTrue(memChunk == null || memChunk.isEmpty()); } @@ -716,7 +719,7 @@ public class TsFilePlanRedoerTest { new MeasurementSchema("s4", TSDataType.FLOAT, TSEncoding.RLE), new MeasurementSchema("s5", TSDataType.TEXT, TSEncoding.PLAIN))); ReadOnlyMemChunk memChunk = - recoveryMemTable.query(new QueryContext(), fullPath, Long.MIN_VALUE, null, null); + recoveryMemTable.query(new QueryContext(false), fullPath, Long.MIN_VALUE, null, null); IPointReader iterator = memChunk.getPointReader(); time = 6; while (iterator.hasNextTimeValuePair()) { diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java index 1291540be05..66f33554c9f 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java @@ -82,7 +82,7 @@ public class EnvironmentUtils { private static final TierManager tierManager = TierManager.getInstance(); public static long TEST_QUERY_JOB_ID = 1; - public static QueryContext TEST_QUERY_CONTEXT = new QueryContext(TEST_QUERY_JOB_ID); + public static QueryContext TEST_QUERY_CONTEXT = new QueryContext(TEST_QUERY_JOB_ID, false); public static FragmentInstanceContext TEST_QUERY_FI_CONTEXT = FragmentInstanceContext.createFragmentInstanceContextForCompaction(TEST_QUERY_JOB_ID); @@ -279,7 +279,7 @@ public class EnvironmentUtils { DeviceIDFactory.getInstance().reset(); TEST_QUERY_JOB_ID = QueryResourceManager.getInstance().assignQueryId(); - TEST_QUERY_CONTEXT = new QueryContext(TEST_QUERY_JOB_ID); + TEST_QUERY_CONTEXT = new QueryContext(TEST_QUERY_JOB_ID, false); } private static void createAllDir() {
