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 2025/01/21 06:27:37 UTC

(iotdb) 01/01: finish

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

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

commit 7535ef677e09db8afafa7dc0ee50863a0ebf8a75
Author: OneSizeFitQuorum <ta...@apache.org>
AuthorDate: Tue Jan 21 14:27:21 2025 +0800

    finish
    
    Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
 .../iotdb/db/protocol/thrift/impl/DataNodeRegionManager.java  |  4 ++--
 .../queryengine/execution/executor/RegionWriteExecutor.java   | 11 ++++++++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeRegionManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeRegionManager.java
index a2dddacda48..4fc2cfbff9c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeRegionManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeRegionManager.java
@@ -99,8 +99,8 @@ public class DataNodeRegionManager {
 
   public ReentrantReadWriteLock getRegionLock(ConsensusGroupId consensusGroupId) {
     return consensusGroupId instanceof DataRegionId
-        ? dataRegionLockMap.get((DataRegionId) consensusGroupId)
-        : schemaRegionLockMap.get((SchemaRegionId) consensusGroupId);
+        ? dataRegionLockMap.get(consensusGroupId)
+        : schemaRegionLockMap.get(consensusGroupId);
   }
 
   public TSStatus createSchemaRegion(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java
index e9d0e2e7feb..079238309c7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java
@@ -148,9 +148,14 @@ public class RegionWriteExecutor {
   @SuppressWarnings("squid:S1181")
   public RegionExecutionResult execute(ConsensusGroupId groupId, PlanNode planNode) {
     try {
-      WritePlanNodeExecutionContext context =
-          new WritePlanNodeExecutionContext(groupId, regionManager.getRegionLock(groupId));
-      return planNode.accept(executionVisitor, context);
+      ReentrantReadWriteLock lock = regionManager.getRegionLock(groupId);
+      if (lock == null) {
+        return RegionExecutionResult.create(
+            false,
+            "Failed to get the lock of the region because the region is not existed.",
+            RpcUtils.getStatus(TSStatusCode.NO_AVAILABLE_REGION_GROUP));
+      }
+      return planNode.accept(executionVisitor, new WritePlanNodeExecutionContext(groupId, lock));
     } catch (Throwable e) {
       LOGGER.warn(e.getMessage(), e);
       return RegionExecutionResult.create(