yuqi1129 opened a new issue, #13173:
URL: https://github.com/apache/gravitino/issues/13173

   ### Describe the subtask
   
   `importTable` trusts the `StringIdentifier` found in the external table's 
properties and writes the row with `overwrite = true`. `table_id` is the 
primary key, so a copied id (`CREATE TABLE t2 LIKE t1`, a copy tool, a restored 
backup) makes `insertTableMetaOnDuplicateKeyUpdate` **rename the existing row** 
to the new name/parent and move its owner, tags, policies, role grants and 
statistics with it. The next load of the original table moves them back; the 
two tables keep swapping one identity.
   
   `ViewMetaService`, `FunctionMetaService` and `TagMetaService` already guard 
this with `OccWriteSupport.findAndLockForOverwrite`; `TableMetaService`, 
`SchemaMetaService` and `TopicMetaService` do not, and none of them covers a 
same-parent, different-name collision.
   
   Proposed change:
   - At import, find the registration that owns the external 
`StringIdentifier`. If its old name still exists externally, reject the copied 
identifier with an actionable client error. If the old name is gone, treat it 
as an external rename.
   - Guard cross-parent overwrites in the relational store. For a same-parent 
rename, use the store's version-checked update so two nodes that observed the 
same old owner cannot both re-bind its ID.
   - On collision, keep the existing row and its attachments in place. The user 
can remove the copied `gravitino.identifier` property and retry the import, 
which will assign a new ID.
   - Account for the MySQL/PostgreSQL difference: on MySQL a natural-key 
conflict keeps the old `table_id`; on PostgreSQL it fails. The copied ID must 
not move an existing row on either backend.
   - Test the dispatcher race and copied identifiers; verify relational store 
behavior on H2/MySQL/PostgreSQL.
   
   Design: implementation design Part 1 (F3 / E3). Gate G1.
   
   ### Parent issue
   
   https://github.com/apache/gravitino/issues/10238


-- 
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]

Reply via email to