diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/RefreshManager.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/RefreshManager.java index d017ba7829fd1a..52694e5a5bdffb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/RefreshManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/RefreshManager.java @@ -76,7 +76,7 @@ public void replayRefreshCatalog(CatalogLog log) { private void refreshCatalogInternal(CatalogIf catalog, boolean invalidCache) { String catalogName = catalog.getName(); if (!catalogName.equals(InternalCatalog.INTERNAL_CATALOG_NAME)) { - ((ExternalCatalog) catalog).onRefresh(invalidCache); + ((ExternalCatalog) catalog).onRefreshCache(invalidCache); LOG.info("refresh catalog {} with invalidCache {}", catalogName, invalidCache); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java index b6e94c3d39d556..7f8c0c71b51b16 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java @@ -388,6 +388,15 @@ public void onRefresh(boolean invalidCache) { synchronized (this.propLock) { this.convertedProperties = null; } + + refreshOnlyCatalogCache(invalidCache); + } + + public void onRefreshCache(boolean invalidCache) { + refreshOnlyCatalogCache(invalidCache); + } + + private void refreshOnlyCatalogCache(boolean invalidCache) { if (useMetaCache.isPresent()) { if (useMetaCache.get() && metaCache != null) { metaCache.invalidateAll(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java index dcfc6d1ad33f90..e855affc31a9de 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java @@ -126,7 +126,7 @@ public void createDb(CreateDbStmt stmt) throws DdlException { catalogDatabase.setProperties(properties); catalogDatabase.setComment(properties.getOrDefault("comment", "")); client.createDatabase(catalogDatabase); - catalog.onRefresh(true); + catalog.onRefreshCache(true); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } @@ -146,7 +146,7 @@ public void dropDb(DropDbStmt stmt) throws DdlException { } try { client.dropDatabase(dbName); - catalog.onRefresh(true); + catalog.onRefreshCache(true); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java index a6933f83d76d50..dd4792715e8b1f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java @@ -107,7 +107,7 @@ public void createDb(CreateDbStmt stmt) throws DdlException { } } nsCatalog.createNamespace(Namespace.of(dbName), properties); - dorisCatalog.onRefresh(true); + dorisCatalog.onRefreshCache(true); } @Override @@ -123,7 +123,7 @@ public void dropDb(DropDbStmt stmt) throws DdlException { } SupportsNamespaces nsCatalog = (SupportsNamespaces) catalog; nsCatalog.dropNamespace(Namespace.of(dbName)); - dorisCatalog.onRefresh(true); + dorisCatalog.onRefreshCache(true); } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalog.java index 73b6639c7b95fd..80cc0f554f637e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalog.java @@ -121,6 +121,11 @@ public void onRefresh(boolean invalidCache) { } } + @Override + public void onRefreshCache(boolean invalidCache) { + onRefresh(invalidCache); + } + @Override public void onClose() { super.onClose(); diff --git a/fe/fe-core/src/test/java/org/apache/doris/datasource/RefreshCatalogTest.java b/fe/fe-core/src/test/java/org/apache/doris/datasource/RefreshCatalogTest.java index 439385993f901b..b51d6b19be507e 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/datasource/RefreshCatalogTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/datasource/RefreshCatalogTest.java @@ -155,18 +155,7 @@ public void testRefreshCatalogLastUpdateTime() throws Exception { } catch (Exception e) { // Do nothing } - Assertions.assertFalse(((ExternalCatalog) test2).isInitialized()); - table.makeSureInitialized(); Assertions.assertTrue(((ExternalCatalog) test2).isInitialized()); - // table.makeSureInitialized() triggered init method - long l4 = test2.getLastUpdateTime(); - Assertions.assertTrue(l4 > l3); - try { - DdlExecutor.execute(Env.getCurrentEnv(), refreshCatalogStmt); - } catch (Exception e) { - // Do nothing - } - Assertions.assertFalse(((ExternalCatalog) test2).isInitialized()); } public static class RefreshCatalogProvider implements TestExternalCatalog.TestCatalogProvider {