Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#5252] fix(catalog): fix disable catalog miss invalidate cache (#5253)

mchades5ec0d5412cb6
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 5360f9f781..045c0ad694 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 ed300e45c7..959f91f5c9 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);
}