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

jiangtian 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 7515568c8e4 Fixed the NPE caused by concurrent "check for 
createTimeSeries" and deleteTimeSeries (#16742)
7515568c8e4 is described below

commit 7515568c8e4649fdbb793a5cd539f299be734281
Author: Caideyipi <[email protected]>
AuthorDate: Wed Nov 12 21:44:35 2025 +0800

    Fixed the NPE caused by concurrent "check for createTimeSeries" and 
deleteTimeSeries (#16742)
    
    * befix
    
    * shi
---
 .../apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java    | 5 ++++-
 .../db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java   | 6 +++++-
 .../db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java   | 6 +++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java
index 916e52b4aca..c087d638d4a 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java
@@ -146,7 +146,10 @@ public interface ISchemaRegion {
    * @param aliasList a list of alias that you want to check
    * @return returns a map contains index of the measurements or alias that 
threw the exception, and
    *     exception details. The exceptions describe whether the measurement or 
alias exists. For
-   *     example, a MeasurementAlreadyExistException means this measurement 
exists.
+   *     example, a MeasurementAlreadyExistException means this measurement 
exists. If there are
+   *     exceptions during check, this may return an empty map, then all the 
measurements will be
+   *     re-checked under consensus layer, which guarantees safety(Yet may 
cause unnecessary replay
+   *     of raft log)
    */
   Map<Integer, MetadataException> checkMeasurementExistence(
       final PartialPath devicePath,
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
index a39b54675ac..3ef9190ab44 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
@@ -874,7 +874,11 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
   @Override
   public Map<Integer, MetadataException> checkMeasurementExistence(
       PartialPath devicePath, List<String> measurementList, List<String> 
aliasList) {
-    return mTree.checkMeasurementExistence(devicePath, measurementList, 
aliasList);
+    try {
+      return mTree.checkMeasurementExistence(devicePath, measurementList, 
aliasList);
+    } catch (final Exception e) {
+      return Collections.emptyMap();
+    }
   }
 
   @Override
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java
index 58e8fd786a5..944ffe0ea53 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java
@@ -855,7 +855,11 @@ public class SchemaRegionPBTreeImpl implements 
ISchemaRegion {
   @Override
   public Map<Integer, MetadataException> checkMeasurementExistence(
       PartialPath devicePath, List<String> measurementList, List<String> 
aliasList) {
-    return mtree.checkMeasurementExistence(devicePath, measurementList, 
aliasList);
+    try {
+      return mtree.checkMeasurementExistence(devicePath, measurementList, 
aliasList);
+    } catch (final Exception e) {
+      return Collections.emptyMap();
+    }
   }
 
   @Override

Reply via email to