zhang-arvin opened a new pull request, #13728:
URL: https://github.com/apache/gravitino/pull/13728
### What changes were proposed in this pull request?
Dropping an unmanaged catalog registration with force leaves its external
schemas and tables in place. Those objects still carry the Gravitino identifier
that was written into them at create/import time (the `gravitino.identifier`
property or the "From Gravitino, DO NOT EDIT" snippet in comments), so a
catalog created later that manages the same external objects imports the stale
id and inherits the previous ownership.
This change makes `CatalogManager.dropCatalog` collect the schemas that
remain in the external system after an unmanaged catalog is dropped, and pass
their identifiers to the connector through a new callback:
```java
default void onCatalogDropped(List<NameIdentifier> remainingExternalSchemas)
{
onCatalogDropped();
}
```
Connectors that store identifiers on external objects override the callback
and strip them. The default forwards to the existing no-arg
`onCatalogDropped()`, so existing connectors (for example the Iceberg one) stay
source compatible.
### Why are the changes needed?
Issue #13475: after a forced drop, recreating the catalog imports stale ids.
#13197 handles the soft-deleted metadata rows in the entity store, but the
identifiers embedded in the external objects themselves were never cleared, so
the newly imported entity reuses the old id.
### Does this PR introduce _any_ user-facing change?
No. It defines the extension point and defines the failure behaviour:
cleanup is best-effort. If the external schemas cannot be listed, or a
connector fails to clear an identifier, the failure is logged and the drop
still succeeds.
### How was this patch tested?
Added two regression tests in `TestCatalogManager`:
- `testDropUnmanagedCatalogCleansResidualExternalIdentifiers`: a forced drop
of an unmanaged catalog hands the connector the schemas that remain externally.
- `testDropManagedCatalogPassesNoExternalSchemasForCleanup`: a managed
catalog passes an empty list, because its external objects are dropped with the
registration.
`./gradlew :core:test --tests "org.apache.gravitino.catalog.*"` passes, and
`./gradlew :core:spotlessApply` is clean.
Fixes #13475
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]