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 db7729a3161 Fixed the bug that the tree model database deletion may 
clear the table model cache
db7729a3161 is described below

commit db7729a31615ed54f24688679c7d88fb54944704
Author: Caideyipi <[email protected]>
AuthorDate: Fri May 30 09:21:53 2025 +0800

    Fixed the bug that the tree model database deletion may clear the table 
model cache
---
 .../iotdb/relational/it/schema/IoTDBDatabaseIT.java      |  5 ++++-
 .../confignode/procedure/env/ConfigNodeProcedureEnv.java | 16 ++++++++--------
 .../thrift/impl/DataNodeInternalRPCServiceImpl.java      | 10 ++++++----
 3 files changed, 18 insertions(+), 13 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 eb835eb44c2..af60c0e4a2a 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
@@ -769,6 +769,10 @@ public class IoTDBDatabaseIT {
     try (final Connection connection =
             EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
         final Statement statement = connection.createStatement()) {
+      statement.execute("use test");
+      // Avoid clearing table cache
+      statement.execute("select * from table1");
+
       try (final ResultSet resultSet = statement.executeQuery("SHOW DATABASES 
DETAILS")) {
         assertTrue(resultSet.next());
         assertEquals("information_schema", resultSet.getString(1));
@@ -778,7 +782,6 @@ public class IoTDBDatabaseIT {
       }
 
       // Test adjustMaxRegionGroupNum
-      statement.execute("use test");
       statement.execute(
           "create table table2(region_id STRING TAG, plant_id STRING TAG, 
color STRING ATTRIBUTE, temperature FLOAT FIELD, speed DOUBLE FIELD)");
       statement.execute(
diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java
index 7b45847fc07..960d0a7977f 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java
@@ -156,18 +156,18 @@ public class ConfigNodeProcedureEnv {
   }
 
   /**
-   * @param storageGroupName database name
+   * @param databaseName database name
    * @return ALL SUCCESS OR NOT
    * @throws IOException IOE
    * @throws TException Thrift IOE
    */
-  public boolean invalidateCache(final String storageGroupName) throws 
IOException, TException {
-    List<TDataNodeConfiguration> allDataNodes = 
getNodeManager().getRegisteredDataNodes();
-    TInvalidateCacheReq invalidateCacheReq = new TInvalidateCacheReq();
+  public boolean invalidateCache(final String databaseName) throws 
IOException, TException {
+    final List<TDataNodeConfiguration> allDataNodes = 
getNodeManager().getRegisteredDataNodes();
+    final TInvalidateCacheReq invalidateCacheReq = new TInvalidateCacheReq();
     invalidateCacheReq.setStorageGroup(true);
-    invalidateCacheReq.setFullPath(storageGroupName);
-    for (TDataNodeConfiguration dataNodeConfiguration : allDataNodes) {
-      int dataNodeId = dataNodeConfiguration.getLocation().getDataNodeId();
+    invalidateCacheReq.setFullPath(databaseName);
+    for (final TDataNodeConfiguration dataNodeConfiguration : allDataNodes) {
+      final int dataNodeId = 
dataNodeConfiguration.getLocation().getDataNodeId();
 
       // If the node is not alive, retry for up to 10 times
       NodeStatus nodeStatus = getLoadManager().getNodeStatus(dataNodeId);
@@ -176,7 +176,7 @@ public class ConfigNodeProcedureEnv {
         for (int i = 0; i < retryNum && nodeStatus == NodeStatus.Unknown; i++) 
{
           try {
             TimeUnit.MILLISECONDS.sleep(500);
-          } catch (InterruptedException e) {
+          } catch (final InterruptedException e) {
             LOG.error("Sleep failed in ConfigNodeProcedureEnv: ", e);
             Thread.currentThread().interrupt();
             break;
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
index 68c9cb8aa15..368b3b027d1 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
@@ -586,10 +586,12 @@ public class DataNodeInternalRPCServiceImpl implements 
IDataNodeRPCService.Iface
       TreeDeviceSchemaCacheManager.getInstance().takeWriteLock();
       try {
         final String database = req.getFullPath();
-        // req.getFullPath() is a database path
-        ClusterTemplateManager.getInstance().invalid(database);
-        // clear table related cache
-        DataNodeTableCache.getInstance().invalid(database);
+        if (PathUtils.isTableModelDatabase(database)) {
+          // clear table related cache
+          DataNodeTableCache.getInstance().invalid(database);
+        } else {
+          ClusterTemplateManager.getInstance().invalid(database);
+        }
         tableDeviceSchemaCache.invalidate(database);
         LOGGER.info("Schema cache of {} has been invalidated", 
req.getFullPath());
         return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());

Reply via email to