roryqi commented on code in PR #13771:
URL: https://github.com/apache/gravitino/pull/13771#discussion_r4266499497
##########
core/src/main/java/org/apache/gravitino/catalog/ViewOperationDispatcher.java:
##########
@@ -147,8 +148,33 @@ public View loadView(NameIdentifier ident) throws
NoSuchViewException {
NameIdentifier schemaIdent =
NameIdentifier.of(ident.namespace().levels());
schemaDispatcher.loadSchema(schemaIdent);
- entityCombinedView =
- TreeLockUtils.doWithTreeLock(schemaIdent, LockType.WRITE, () ->
importView(ident));
+ try {
+ entityCombinedView =
+ TreeLockUtils.doWithTreeLock(schemaIdent, LockType.WRITE, () ->
importView(ident));
+ } catch (EntityAlreadyExistsException e) {
+ // A create-only import can conflict either because another Gravitino
node won an HA race,
+ // or because the external identifier is already stored under another
Gravitino path.
+ // Reload to distinguish a successful concurrent import from an
identity conflict.
+ LOG.info("View {} import conflicted with existing metadata; reloading
from store.", ident);
+ entityCombinedView =
+ TreeLockUtils.doWithTreeLock(ident, LockType.READ, () ->
internalLoadView(ident));
+ if (!entityCombinedView.imported()) {
+ throw new UnsupportedOperationException(
+ "View "
+ + ident
+ + " cannot be imported because its name or external
identifier is already "
+ + "managed under a different Gravitino identifier. Gravitino
does not "
+ + "automatically reconcile external view renames or stale
registrations. "
+ + "Before retrying, manually resolve the conflict: either
restore the external "
+ + "view name and identifier to match its Gravitino
registration, or have an "
+ + "administrator safely remove the stale Gravitino
registration and its "
+ + "privileges, tags, and other relationships. Do not only
remove "
+ + "`gravitino.identifier` while the conflicting registration
remains, because "
+ + "Gravitino may associate the external view with that
registration. After the "
+ + "stale registration is removed, clear
`gravitino.identifier` from the external "
+ + "view and load it again.");
Review Comment:
Addressed in 69495771f8.
Added
`OperationDispatcher.retainedExternalIdentifierConflictException(NameIdentifier,
EntityType)` and replaced the duplicate schema, table, and view message blocks
with calls to that shared helper. This keeps the entity-specific noun while
centralizing the recovery wording alongside
`softDeletedExternalIdentifierException`.
The schema, table, and view dispatcher tests pass. Leaving this thread
unresolved for reviewer confirmation.
--
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]