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

jshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 5ec0d5412 [#5252] fix(catalog): fix disable catalog miss invalidate 
cache (#5253)
5ec0d5412 is described below

commit 5ec0d5412cb66b2c9484d93f590731d9932cf490
Author: mchades <[email protected]>
AuthorDate: Fri Oct 25 14:04:40 2024 +0800

    [#5252] fix(catalog): fix disable catalog miss invalidate cache (#5253)
    
    ### What changes were proposed in this pull request?
    
     fix disable catalog miss invalidate cache
    
    ### Why are the changes needed?
    
    Fix: #5252
    
    ### Does this PR introduce _any_ user-facing change?
    
    no
    
    ### How was this patch tested?
    
    tests added
---
 .../org/apache/gravitino/client/integration/test/CatalogIT.java    | 7 +++++++
 .../src/main/java/org/apache/gravitino/catalog/CatalogManager.java | 2 ++
 2 files changed, 9 insertions(+)

diff --git 
a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java
 
b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java
index 5360f9f78..045c0ad69 100644
--- 
a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java
+++ 
b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java
@@ -163,6 +163,7 @@ public class CatalogIT extends BaseIT {
             catalogName, Catalog.Type.FILESET, "hadoop", "catalog comment", 
ImmutableMap.of());
     Assertions.assertEquals("true", catalog.properties().get(PROPERTY_IN_USE));
 
+    // test in-use and can't drop
     Exception exception =
         Assertions.assertThrows(
             CatalogInUseException.class, () -> 
metalake.dropCatalog(catalogName));
@@ -170,10 +171,16 @@ public class CatalogIT extends BaseIT {
         exception.getMessage().contains("please disable it first or use force 
option"),
         exception.getMessage());
 
+    // test disable and enable again
     Assertions.assertDoesNotThrow(() -> metalake.disableCatalog(catalogName));
     Catalog loadedCatalog = metalake.loadCatalog(catalogName);
     Assertions.assertEquals("false", 
loadedCatalog.properties().get(PROPERTY_IN_USE));
 
+    Assertions.assertDoesNotThrow(() -> metalake.enableCatalog(catalogName));
+    loadedCatalog = metalake.loadCatalog(catalogName);
+    Assertions.assertEquals("true", 
loadedCatalog.properties().get(PROPERTY_IN_USE));
+
+    Assertions.assertDoesNotThrow(() -> metalake.disableCatalog(catalogName));
     exception =
         Assertions.assertThrows(
             CatalogNotInUseException.class,
diff --git 
a/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java 
b/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java
index ed300e45c..959f91f5c 100644
--- a/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java
+++ b/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java
@@ -513,6 +513,8 @@ public class CatalogManager implements CatalogDispatcher, 
Closeable {
 
             return newCatalogBuilder.build();
           });
+      catalogCache.invalidate(ident);
+
     } catch (IOException e) {
       throw new RuntimeException(e);
     }

Reply via email to