This is an automated email from the ASF dual-hosted git repository.
roryqi 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 4e75f81be7 [#6845] fix(core): handle NonEmptyEntityException while
dropSchema (#6978)
4e75f81be7 is described below
commit 4e75f81be783df479c4767d27c9f8505690cf310
Author: Jimmy Lee <[email protected]>
AuthorDate: Thu Apr 24 13:44:36 2025 +0800
[#6845] fix(core): handle NonEmptyEntityException while dropSchema (#6978)
### 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: 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) {