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

jt2594838 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 0f91bed7544 Fix schema existence check fail-open behavior (#18755)
0f91bed7544 is described below

commit 0f91bed7544464f3fcb7f46d3bdf8c50669ed9b8
Author: Caideyipi <[email protected]>
AuthorDate: Mon Oct 12 13:57:23 2026 +0800

    Fix schema existence check fail-open behavior (#18755)
    
    * Fix schema existence check fail-open behavior
    
    * Fix PR 18755 encoding and compilation issues
---
 .../iotdb/db/schemaengine/schemaregion/ISchemaRegion.java      | 10 ++++------
 .../schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java | 10 +++-------
 .../schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java | 10 +++-------
 .../schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java |  4 +++-
 4 files changed, 13 insertions(+), 21 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 540d5d4274c..5618b7acd7e 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
@@ -77,7 +77,7 @@ import java.util.concurrent.atomic.AtomicInteger;
  * <p>The interfaces are divided as following:
  *
  * <ol>
- *   <li>Interfaces for initialization、recover and clear
+ *   <li>Interfaces for initialization, recover and clear
  *   <li>Interfaces for schema region Info query and operation
  *   <li>Interfaces for Timeseries operation
  *   <li>Interfaces for metadata info Query
@@ -91,7 +91,7 @@ import java.util.concurrent.atomic.AtomicInteger;
  */
 public interface ISchemaRegion {
 
-  // region Interfaces for initialization、recover and clear
+  // region Interfaces for initialization, recover and clear
   void init() throws MetadataException;
 
   /** clear all metadata components of this schemaRegion */
@@ -154,10 +154,8 @@ 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. 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)
+   *     example, a MeasurementAlreadyExistException means this measurement 
exists. An empty map
+   *     means that no measurement exists and can be created.
    */
   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 14f147d69f2..e15e7e132c8 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
@@ -182,7 +182,7 @@ import static 
org.apache.tsfile.common.constant.TsFileConstant.PATH_SEPARATOR;
  * <p>The codes are divided into the following code regions:
  *
  * <ol>
- *   <li>Interfaces and Implementation for initialization、recover and clear
+ *   <li>Interfaces and Implementation for initialization, recover and clear
  *   <li>Interfaces and Implementation for schema region Info query and 
operation
  *   <li>Interfaces and Implementation for Timeseries operation
  *   <li>Interfaces for auto create device
@@ -229,7 +229,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
   private IDeviceAttributeStore deviceAttributeStore;
   private DeviceAttributeCacheUpdater deviceAttributeCacheUpdater;
 
-  // region Interfaces and Implementation of initialization、snapshot、recover 
and clear
+  // region Interfaces and Implementation of initialization, snapshot, recover 
and clear
   public SchemaRegionMemoryImpl(final ISchemaRegionParams schemaRegionParams)
       throws MetadataException {
 
@@ -899,11 +899,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
   @Override
   public Map<Integer, MetadataException> checkMeasurementExistence(
       PartialPath devicePath, List<String> measurementList, List<String> 
aliasList) {
-    try {
-      return mTree.checkMeasurementExistence(devicePath, measurementList, 
aliasList);
-    } catch (final Exception e) {
-      return Collections.emptyMap();
-    }
+    return mTree.checkMeasurementExistence(devicePath, measurementList, 
aliasList);
   }
 
   @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 fa4b815e224..6766adf8212 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
@@ -143,7 +143,7 @@ import static 
org.apache.tsfile.common.constant.TsFileConstant.PATH_SEPARATOR;
  * <p>The codes are divided into the following code regions:
  *
  * <ol>
- *   <li>Interfaces and Implementation for initialization、recover and clear
+ *   <li>Interfaces and Implementation for initialization, recover and clear
  *   <li>Interfaces and Implementation for schema region Info query and 
operation
  *   <li>Interfaces and Implementation for Timeseries operation
  *   <li>Interfaces for auto create device
@@ -187,7 +187,7 @@ public class SchemaRegionPBTreeImpl implements 
ISchemaRegion {
   private MTreeBelowSGCachedImpl mtree;
   private TagManager tagManager;
 
-  // region Interfaces and Implementation of initialization、snapshot、recover 
and clear
+  // region Interfaces and Implementation of initialization, snapshot, recover 
and clear
   public SchemaRegionPBTreeImpl(ISchemaRegionParams schemaRegionParams) throws 
MetadataException {
 
     storageGroupFullPath = schemaRegionParams.getDatabase();
@@ -888,11 +888,7 @@ public class SchemaRegionPBTreeImpl implements 
ISchemaRegion {
   @Override
   public Map<Integer, MetadataException> checkMeasurementExistence(
       PartialPath devicePath, List<String> measurementList, List<String> 
aliasList) {
-    try {
-      return mtree.checkMeasurementExistence(devicePath, measurementList, 
aliasList);
-    } catch (final Exception e) {
-      return Collections.emptyMap();
-    }
+    return mtree.checkMeasurementExistence(devicePath, measurementList, 
aliasList);
   }
 
   @Override
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java
index e6ee1e36ffa..f181766731d 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java
@@ -608,8 +608,10 @@ public class MTreeBelowSGCachedImpl {
     ICachedMNode device;
     try {
       device = getNodeByPath(devicePath);
-    } catch (MetadataException e) {
+    } catch (PathNotExistException e) {
       return Collections.emptyMap();
+    } catch (MetadataException e) {
+      return Collections.singletonMap(0, e);
     }
     try {
       if (!device.isDevice()) {

Reply via email to