yuqi1129 opened a new pull request, #13197: URL: https://github.com/apache/gravitino/pull/13197
### What changes were proposed in this pull request? Two layers, because the store alone cannot tell an external rename from a copied id: 1. **Store** — `OccWriteSupport.checkOverwriteIdNotOwnedByOtherParent`, used by `TableMetaService`, `SchemaMetaService` and `TopicMetaService` when `overwrite = true`: lock the row that owns the incoming id (`FOR UPDATE`) and throw `EntityAlreadyExistsException` if it lives under another parent. This is the guard `View`/`Function`/`Tag` already had. A same-parent match is still allowed — that is how an external rename is re-registered. 2. **Dispatcher** — `TableOperationDispatcher`/`SchemaOperationDispatcher.checkImportedIdNotCopied`: when an import finds an id that is already registered under another name in the same parent, ask the external catalog whether that owner still exists. If it does, the id was copied (`CREATE TABLE t2 LIKE t1` carries `TBLPROPERTIES`): fail with a `GravitinoRuntimeException` that names both tables and the property to remove. If it does not, it was a rename: re-bind as before. ### Why are the changes needed? `importTable` trusts the `StringIdentifier` in the external properties and upserts by primary key, so a copied id **renamed the existing row** and moved its owner, tags, policies, role grants and statistics to the copy; the next load of the original moved them back. Cross-parent copies are now rejected in the store; same-parent copies are rejected in the dispatcher. Fix: #13173 ### Does this PR introduce _any_ user-facing change? Loading a table/schema whose properties carry another live table's `gravitino.identifier` now fails with an explanatory error instead of silently moving the original's metadata. ### How was this patch tested? New tests: `testOverwriteRejectsIdOwnedBy*InAnother*` and `testOverwriteRebindsIdWithinTheSameSchema` in the table/schema/topic meta-service tests (H2, MySQL, PostgreSQL); `testLoad*RejectsCopiedIdentifierWhileSourceStillExists` and `testLoad*RebindsIdentifierAfterExternalRename` in the table/schema dispatcher tests. -- 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]
