This is an automated email from the ASF dual-hosted git repository.
roryqi pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-0.9 by this push:
new d2a10dad09 [#6845] fix(core): handle NonEmptyEntityException while
dropSchema (#7061)
d2a10dad09 is described below
commit d2a10dad097309f09e982a846d253bde3e39aac2
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Apr 24 14:42:13 2025 +0800
[#6845] fix(core): handle NonEmptyEntityException while dropSchema (#7061)
### What changes were proposed in this pull request?
Catch the NonEmptyEntityException exception while dropSchema.
### Why are the changes needed?
Fix: #6845
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
1. Create a schema and a table in MySQL or PG catalog in Gravitino UI
2. Drop the table by mysql client or psql cli
3. Drop the schema in Gravitino UI
4. No exception occurs
Co-authored-by: Jimmy Lee <[email protected]>
Co-authored-by: mchades <[email protected]>
---
.../catalog/mysql/integration/test/CatalogMysqlIT.java | 17 +++++++++++++++++
.../gravitino/catalog/SchemaOperationDispatcher.java | 2 +-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git
a/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java
b/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java
index 7c713fc7ec..8b84806ba8 100644
---
a/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java
+++
b/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java
@@ -923,6 +923,23 @@ public class CatalogMysqlIT extends BaseIT {
() -> {
schemas.loadSchema(schemaName);
});
+
+ // test drop inconsistent database
+ catalog
+ .asSchemas()
+ .createSchema(schemaName, null, ImmutableMap.<String,
String>builder().build());
+ catalog
+ .asTableCatalog()
+ .createTable(
+ NameIdentifier.of(schemaName, tableName),
+ createColumns(),
+ "Created by Gravitino client",
+ ImmutableMap.<String, String>builder().build());
+ // drop the table externally
+ mysqlService.executeQuery("DROP TABLE " + schemaName + "." + tableName);
+
+ // drop the schema without cascade
+ Assertions.assertTrue(catalog.asSchemas().dropSchema(schemaName, false));
}
@Test
diff --git
a/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java
b/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java
index a388fff252..b61c99e0d7 100644
---
a/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java
+++
b/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java
@@ -333,7 +333,7 @@ public class SchemaOperationDispatcher extends
OperationDispatcher implements Sc
// return value of the store operation into account. We only take
the return value of the
// catalog into account.
try {
- store.delete(ident, SCHEMA, cascade);
+ store.delete(ident, SCHEMA, true);
} catch (NoSuchEntityException e) {
LOG.warn("The schema to be dropped does not exist in the store:
{}", ident, e);
} catch (Exception e) {