You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ju...@apache.org on 2026/09/29 04:32:44 UTC
(iotdb) 01/01: Fix schema existence check fail-open behavior
This is an automated email from the ASF dual-hosted git repository.
Caideyipi pushed a commit to branch schema-existence-fix-pr
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 84462af01d4ce7c98c8fa68fe00cd69a6708205a
Author: Caideyipi <87...@users.noreply.github.com>
AuthorDate: Tue Sep 29 11:21:48 2026 +0800
Fix schema existence check fail-open behavior
---
.../iotdb/db/schemaengine/schemaregion/ISchemaRegion.java | 10 ++++------
.../schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java | 8 +++++---
.../schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java | 8 +++++---
.../schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java | 4 +++-
4 files changed, 17 insertions(+), 13 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..7ae4dae0d94 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閵嗕购ecover 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閵嗕购ecover 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 7c6fd4d7e53..2536c2f4bb0 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閵嗕购ecover 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
@@ -228,7 +228,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閵嗕够napshot閵嗕购ecover and clear
public SchemaRegionMemoryImpl(final ISchemaRegionParams schemaRegionParams)
throws MetadataException {
@@ -895,8 +895,10 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
PartialPath devicePath, List<String> measurementList, List<String> aliasList) {
try {
return mTree.checkMeasurementExistence(devicePath, measurementList, aliasList);
- } catch (final Exception e) {
+ } catch (final PathNotExistException e) {
return Collections.emptyMap();
+ } catch (final MetadataException e) {
+ return Collections.singletonMap(0, e);
}
}
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 502afed74ea..dba71f86cff 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閵嗕购ecover 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
@@ -186,7 +186,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閵嗕够napshot閵嗕购ecover and clear
public SchemaRegionPBTreeImpl(ISchemaRegionParams schemaRegionParams) throws MetadataException {
storageGroupFullPath = schemaRegionParams.getDatabase();
@@ -878,8 +878,10 @@ public class SchemaRegionPBTreeImpl implements ISchemaRegion {
PartialPath devicePath, List<String> measurementList, List<String> aliasList) {
try {
return mtree.checkMeasurementExistence(devicePath, measurementList, aliasList);
- } catch (final Exception e) {
+ } catch (final PathNotExistException e) {
return Collections.emptyMap();
+ } catch (final MetadataException e) {
+ return Collections.singletonMap(0, e);
}
}
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 188620ef6a5..51cf4df049f 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()) {