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 838dbab4fb5 Made memory not enough exception cause by schema fetching 
retry-able for insertion & Refactor & Fixed the database name bug when alter 
non-exists database
838dbab4fb5 is described below

commit 838dbab4fb5cfe637d1531586b0d6b211c3dfe5a
Author: Caideyipi <[email protected]>
AuthorDate: Wed Apr 2 19:07:05 2025 +0800

    Made memory not enough exception cause by schema fetching retry-able for 
insertion & Refactor & Fixed the database name bug when alter non-exists 
database
---
 .../relational/it/schema/IoTDBDatabaseIT.java      | 11 ++++++++
 .../plan/analyze/ClusterPartitionFetcher.java      | 30 ++++++++++------------
 .../analyze/cache/partition/PartitionCache.java    |  7 ++---
 .../analyze/schema/AutoCreateSchemaExecutor.java   | 14 +++++-----
 .../analyze/schema/ClusterSchemaFetchExecutor.java |  9 +++----
 .../config/executor/ClusterConfigTaskExecutor.java |  2 +-
 .../metadata/fetcher/TableDeviceSchemaFetcher.java |  5 ++--
 .../apache/iotdb/commons/utils/StatusUtils.java    |  1 +
 8 files changed, 43 insertions(+), 36 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
index 491f277c5ef..1b3e9946e36 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
@@ -84,6 +84,17 @@ public class IoTDBDatabaseIT {
       // create duplicated database with IF NOT EXISTS
       statement.execute("create database IF NOT EXISTS test");
 
+      // alter non-exist
+      try {
+        statement.execute("alter database test1 set properties ttl='INF'");
+        fail("alter database test1 shouldn't succeed because test does not 
exist");
+      } catch (final SQLException e) {
+        assertEquals("500: Database test1 doesn't exist", e.getMessage());
+      }
+
+      statement.execute("alter database if exists test1 set properties 
ttl='INF'");
+      statement.execute("alter database test set properties ttl=default");
+
       String[] databaseNames = new String[] {"test"};
       String[] TTLs = new String[] {"INF"};
       int[] schemaReplicaFactors = new int[] {1};
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java
index e7bbaa369a7..ae92d6d7240 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java
@@ -26,7 +26,7 @@ import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
 import org.apache.iotdb.commons.client.IClientManager;
 import org.apache.iotdb.commons.client.exception.ClientManagerException;
 import org.apache.iotdb.commons.consensus.ConfigRegionId;
-import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
 import org.apache.iotdb.commons.partition.DataPartition;
 import org.apache.iotdb.commons.partition.DataPartitionQueryParam;
 import org.apache.iotdb.commons.partition.SchemaNodeManagementPartition;
@@ -114,10 +114,9 @@ public class ClusterPartitionFetcher implements 
IPartitionFetcher {
           partitionCache.updateSchemaPartitionCache(
               schemaPartitionTableResp.getSchemaPartitionTable());
         } else {
-          throw new RuntimeException(
-              new IoTDBException(
-                  schemaPartitionTableResp.getStatus().getMessage(),
-                  schemaPartitionTableResp.getStatus().getCode()));
+          throw new IoTDBRuntimeException(
+              schemaPartitionTableResp.getStatus().getMessage(),
+              schemaPartitionTableResp.getStatus().getCode());
         }
       }
       return schemaPartition;
@@ -146,10 +145,9 @@ public class ClusterPartitionFetcher implements 
IPartitionFetcher {
           partitionCache.updateSchemaPartitionCache(
               schemaPartitionTableResp.getSchemaPartitionTable());
         } else {
-          throw new RuntimeException(
-              new IoTDBException(
-                  schemaPartitionTableResp.getStatus().getMessage(),
-                  schemaPartitionTableResp.getStatus().getCode()));
+          throw new IoTDBRuntimeException(
+              schemaPartitionTableResp.getStatus().getMessage(),
+              schemaPartitionTableResp.getStatus().getCode());
         }
       }
       return schemaPartition;
@@ -274,10 +272,9 @@ public class ClusterPartitionFetcher implements 
IPartitionFetcher {
           dataPartition = parseDataPartitionResp(dataPartitionTableResp);
           
partitionCache.updateDataPartitionCache(dataPartitionTableResp.getDataPartitionTable());
         } else {
-          throw new RuntimeException(
-              new IoTDBException(
-                  dataPartitionTableResp.getStatus().getMessage(),
-                  dataPartitionTableResp.getStatus().getCode()));
+          throw new IoTDBRuntimeException(
+              dataPartitionTableResp.getStatus().getMessage(),
+              dataPartitionTableResp.getStatus().getCode());
         }
       }
     } catch (final ClientManagerException | TException e) {
@@ -343,10 +340,9 @@ public class ClusterPartitionFetcher implements 
IPartitionFetcher {
           partitionCache.updateSchemaPartitionCache(
               schemaPartitionTableResp.getSchemaPartitionTable());
         } else {
-          throw new RuntimeException(
-              new IoTDBException(
-                  schemaPartitionTableResp.getStatus().getMessage(),
-                  schemaPartitionTableResp.getStatus().getCode()));
+          throw new IoTDBRuntimeException(
+              schemaPartitionTableResp.getStatus().getMessage(),
+              schemaPartitionTableResp.getStatus().getCode());
         }
       }
       return schemaPartition;
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
index d04e616a90a..15828538c7f 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
@@ -29,6 +29,7 @@ import org.apache.iotdb.commons.client.IClientManager;
 import org.apache.iotdb.commons.client.exception.ClientManagerException;
 import org.apache.iotdb.commons.consensus.ConfigRegionId;
 import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.memory.IMemoryBlock;
 import org.apache.iotdb.commons.memory.MemoryBlockType;
@@ -338,7 +339,7 @@ public class PartitionCache {
                 "[{} Cache] failed to create database {}",
                 CacheMetrics.DATABASE_CACHE_NAME,
                 databaseName);
-            throw new RuntimeException(new IoTDBException(tsStatus.message, 
tsStatus.code));
+            throw new IoTDBRuntimeException(tsStatus.message, tsStatus.code);
           }
         }
         // Try to update database cache when all databases have already been 
created
@@ -370,7 +371,7 @@ public class PartitionCache {
                   AuthorityChecker.checkSystemPermission(userName, 
PrivilegeType.MANAGE_DATABASE),
                   PrivilegeType.MANAGE_DATABASE);
           if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) 
{
-            throw new RuntimeException(new IoTDBException(status.getMessage(), 
status.getCode()));
+            throw new IoTDBRuntimeException(status.getMessage(), 
status.getCode());
           }
         }
       } finally {
@@ -387,7 +388,7 @@ public class PartitionCache {
       } else {
         logger.warn(
             "[{} Cache] failed to create database {}", 
CacheMetrics.DATABASE_CACHE_NAME, database);
-        throw new RuntimeException(new IoTDBException(tsStatus.message, 
tsStatus.code));
+        throw new IoTDBRuntimeException(tsStatus.message, tsStatus.code);
       }
     } finally {
       databaseCacheLock.writeLock().unlock();
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java
index aca1a088613..76f88bb18ca 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java
@@ -22,6 +22,7 @@ package org.apache.iotdb.db.queryengine.plan.analyze.schema;
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.auth.entity.PrivilegeType;
 import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
@@ -205,7 +206,7 @@ class AutoCreateSchemaExecutor {
                 AuthorityChecker.checkSystemPermission(userName, 
PrivilegeType.EXTEND_TEMPLATE),
                 PrivilegeType.EXTEND_TEMPLATE);
         if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-          throw new RuntimeException(new IoTDBException(status.getMessage(), 
status.getCode()));
+          throw new IoTDBRuntimeException(status.getMessage(), 
status.getCode());
         }
       }
     } finally {
@@ -226,7 +227,7 @@ class AutoCreateSchemaExecutor {
                 AuthorityChecker.checkSystemPermission(userName, 
PrivilegeType.EXTEND_TEMPLATE),
                 PrivilegeType.EXTEND_TEMPLATE);
         if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-          throw new RuntimeException(new IoTDBException(status.getMessage(), 
status.getCode()));
+          throw new IoTDBRuntimeException(status.getMessage(), 
status.getCode());
         }
       }
     } finally {
@@ -501,7 +502,7 @@ class AutoCreateSchemaExecutor {
     final TSStatus status =
         AuthorityChecker.checkAuthority(statement, 
context.getSession().getUserName());
     if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-      throw new RuntimeException(new IoTDBException(status.getMessage(), 
status.getCode()));
+      throw new IoTDBRuntimeException(status.getMessage(), status.getCode());
     }
 
     ExecutionResult executionResult = executeStatement(statement, context);
@@ -512,8 +513,7 @@ class AutoCreateSchemaExecutor {
     }
 
     if (statusCode != TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
-      throw new RuntimeException(
-          new IoTDBException(executionResult.status.getMessage(), statusCode));
+      throw new IoTDBRuntimeException(executionResult.status.getMessage(), 
statusCode);
     }
 
     final Set<TSStatus> failedCreationSet = new HashSet<>();
@@ -543,7 +543,7 @@ class AutoCreateSchemaExecutor {
     TSStatus status =
         AuthorityChecker.checkAuthority(statement, 
context.getSession().getUserName());
     if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-      throw new RuntimeException(new IoTDBException(status.getMessage(), 
status.getCode()));
+      throw new IoTDBRuntimeException(status.getMessage(), status.getCode());
     }
     ExecutionResult executionResult = executeStatement(statement, context);
     status = executionResult.status;
@@ -561,7 +561,7 @@ class AutoCreateSchemaExecutor {
     TSStatus status =
         AuthorityChecker.checkAuthority(statement, 
context.getSession().getUserName());
     if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-      throw new RuntimeException(new IoTDBException(status.getMessage(), 
status.getCode()));
+      throw new IoTDBRuntimeException(status.getMessage(), status.getCode());
     }
     ExecutionResult executionResult = executeStatement(statement, context);
     status = executionResult.status;
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java
index 45b0f7f1362..16f5420413e 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.db.queryengine.plan.analyze.schema;
 
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
@@ -250,11 +251,9 @@ class ClusterSchemaFetchExecutor {
     try {
       ExecutionResult executionResult = executionStatement(queryId, 
fetchStatement, context);
       if (executionResult.status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-        throw new RuntimeException(
-            new IoTDBException(
-                String.format(
-                    "Fetch Schema failed, because %s", 
executionResult.status.getMessage()),
-                executionResult.status.getCode()));
+        throw new IoTDBRuntimeException(
+            String.format("Fetch Schema failed, because %s", 
executionResult.status.getMessage()),
+            executionResult.status.getCode());
       }
       try (SetThreadName threadName = new 
SetThreadName(executionResult.queryId.getId())) {
         ClusterSchemaTree result = new ClusterSchemaTree();
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index 59313cc4018..8b0966a66eb 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -3596,7 +3596,7 @@ public class ClusterConfigTaskExecutor implements 
IConfigTaskExecutor {
         } else {
           future.setException(
               new IoTDBException(
-                  String.format("Database %s doesn't exist", 
databaseSchema.getName().substring(5)),
+                  String.format("Database %s doesn't exist", 
databaseSchema.getName()),
                   TSStatusCode.DATABASE_NOT_EXIST.getStatusCode()));
         }
       } else {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
index 117699854e1..18228b1a86d 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
@@ -121,9 +121,8 @@ public class TableDeviceSchemaFetcher {
               false);
 
       if (executionResult.status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-        throw new RuntimeException(
-            new IoTDBException(
-                executionResult.status.getMessage(), 
executionResult.status.getCode()));
+        throw new IoTDBRuntimeException(
+            executionResult.status.getMessage(), 
executionResult.status.getCode());
       }
 
       final List<ColumnHeader> columnHeaderList =
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.java
index cd355b34d8c..4ffa36604d6 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.java
@@ -67,6 +67,7 @@ public class StatusUtils {
     NEED_RETRY.add(TSStatusCode.NO_ENOUGH_DATANODE.getStatusCode());
     
NEED_RETRY.add(TSStatusCode.TOO_MANY_CONCURRENT_QUERIES_ERROR.getStatusCode());
     NEED_RETRY.add(TSStatusCode.SYNC_CONNECTION_ERROR.getStatusCode());
+    
NEED_RETRY.add(TSStatusCode.QUERY_EXECUTION_MEMORY_NOT_ENOUGH.getStatusCode());
   }
 
   /**

Reply via email to