This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 0a65556c6fa Fix NPE problem in EXPLAIN ANALYZE
0a65556c6fa is described below
commit 0a65556c6fae48cce7028725e662a3f9f02b26ca
Author: YangCaiyin <[email protected]>
AuthorDate: Fri Mar 22 21:53:22 2024 +0800
Fix NPE problem in EXPLAIN ANALYZE
---
.../db/queryengine/common/DataNodeEndPoints.java | 26 ++++++++++++++++++++++
.../fragment/FragmentInstanceManager.java | 12 +++++-----
.../SimpleFragmentParallelPlanner.java | 5 +----
3 files changed, 33 insertions(+), 10 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/DataNodeEndPoints.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/DataNodeEndPoints.java
index 1ae56e723fd..fcc877f3d28 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/DataNodeEndPoints.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/DataNodeEndPoints.java
@@ -19,6 +19,7 @@
package org.apache.iotdb.db.queryengine.common;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -38,6 +39,31 @@ public class DataNodeEndPoints {
IoTDBDescriptor.getInstance().getConfig().getInternalAddress(),
IoTDBDescriptor.getInstance().getConfig().getInternalPort());
+ public static final TEndPoint LOCAL_DATA_REGION_CONSENSUS_ENDPOINT =
+ new TEndPoint(
+ IoTDBDescriptor.getInstance().getConfig().getInternalAddress(),
+
IoTDBDescriptor.getInstance().getConfig().getDataRegionConsensusPort());
+
+ public static final TEndPoint LOCAL_SCHEMA_REGION_CONSENSUS_CLIENT_ENDPOINT =
+ new TEndPoint(
+ IoTDBDescriptor.getInstance().getConfig().getInternalAddress(),
+
IoTDBDescriptor.getInstance().getConfig().getSchemaRegionConsensusPort());
+
+ public static final TEndPoint LOCAL_CLIENT_RPC_ENDPOINT =
+ new TEndPoint(
+ IoTDBDescriptor.getInstance().getConfig().getRpcAddress(),
+ IoTDBDescriptor.getInstance().getConfig().getRpcPort());
+
+ public static final TDataNodeLocation getLocalDataNodeLocation() {
+ return new TDataNodeLocation(
+ IoTDBDescriptor.getInstance().getConfig().getDataNodeId(),
+ LOCAL_CLIENT_RPC_ENDPOINT,
+ LOCAL_HOST_INTERNAL_ENDPOINT,
+ LOCAL_HOST_DATA_BLOCK_ENDPOINT,
+ LOCAL_DATA_REGION_CONSENSUS_ENDPOINT,
+ LOCAL_SCHEMA_REGION_CONSENSUS_CLIENT_ENDPOINT);
+ }
+
public static boolean isSameNode(TEndPoint endPoint) {
return endPoint.equals(LOCAL_HOST_DATA_BLOCK_ENDPOINT);
}
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 af1fe750490..bea961c7525 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
@@ -317,8 +317,8 @@ public class FragmentInstanceManager {
FragmentInstanceId instanceId) {
requireNonNull(instanceId, "instanceId is null");
// If the instance is still running, we directly get the statistics from
instanceExecution
- if (instanceExecution.containsKey(instanceId)) {
- FragmentInstanceExecution fragmentInstanceExecution =
instanceExecution.get(instanceId);
+ FragmentInstanceExecution fragmentInstanceExecution =
instanceExecution.get(instanceId);
+ if (fragmentInstanceExecution != null) {
try {
fragmentInstanceExecution.lockStatistics();
if (!fragmentInstanceExecution.isStaticsRemoved()) {
@@ -331,11 +331,11 @@ public class FragmentInstanceManager {
// If the instance has finished, we get the statistics which was cached in
the instanceContext
// when instanceExecution was removed.
FragmentInstanceContext context = instanceContext.get(instanceId);
- TFetchFragmentInstanceStatisticsResp statistics =
context.getFragmentInstanceStatistics();
- if (statistics == null) {
- return null;
+ if (context == null) {
+ return new TFetchFragmentInstanceStatisticsResp();
}
- return statistics;
+ TFetchFragmentInstanceStatisticsResp statisticsResp =
context.getFragmentInstanceStatistics();
+ return statisticsResp == null ? new TFetchFragmentInstanceStatisticsResp()
: statisticsResp;
}
private FragmentInstanceInfo createFailedInstanceInfo(FragmentInstanceId
instanceId) {
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 156206d9f14..1394ba96503 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
@@ -166,10 +166,7 @@ public class SimpleFragmentParallelPlanner implements
IFragmentParallelPlaner {
// no data region && no dataNodeLocation, we need to execute this FI
on local
// now only the case AggregationQuery has schemaengine but no data
region will enter here
fragmentInstance.setExecutorAndHost(
- new QueryExecutor(
- new TDataNodeLocation()
-
.setInternalEndPoint(DataNodeEndPoints.LOCAL_HOST_INTERNAL_ENDPOINT)
-
.setMPPDataExchangeEndPoint(DataNodeEndPoints.LOCAL_HOST_DATA_BLOCK_ENDPOINT)));
+ new QueryExecutor(DataNodeEndPoints.getLocalDataNodeLocation()));
}
} else {
fragmentInstance.setExecutorAndHost(new
StorageExecutor(regionReplicaSet));