This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch branch-0.7
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-0.7 by this push:
new 659c352eb [#5252] fix(catalog): fix disable catalog miss invalidate
cache (#5258)
659c352eb is described below
commit 659c352eb0271a916482771fe4038db1977d47f7
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Oct 25 15:19:17 2024 +0800
[#5252] fix(catalog): fix disable catalog miss invalidate cache (#5258)
### 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
Co-authored-by: mchades <[email protected]>
---
.../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);
}