Skip to content

[#13173] fix(core): Refuse an import whose StringIdentifier belongs to another live entity - #13197

Open
yuqi1129 wants to merge 3 commits into
apache:mainfrom
yuqi1129:fix/13173-import-id-check
Open

yuqi1129 wants to merge 3 commits into
apache:mainfrom
yuqi1129:fix/13173-import-id-check

Conversation

@yuqi1129

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Two layers, because the store alone cannot tell an external rename from a copied id:

  1. StoreOccWriteSupport.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. DispatcherTableOperationDispatcher/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.

Copilot AI lite review requested due to automatic review settings September 15, 2026 15:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

Code Coverage Report

Overall Project 70.06% +0.23% 🟢
Files changed 86.35% 🟢

Module Coverage
aliyun 19.74% 🔴
api 51.59% 🟢
authorization-common 85.96% 🟢
authorization-ranger 4.38% 🔴
aws 53.54% 🟢
azure 32.1% 🔴
catalog-common 28.4% 🔴
catalog-fileset 82.2% 🟢
catalog-glue 71.52% 🟢
catalog-hive 83.07% 🟢
catalog-jdbc-common 45.05% +2.54% 🟢
catalog-jdbc-doris 83.47% 🟢
catalog-jdbc-mysql 81.8% 🟢
catalog-jdbc-postgresql 83.89% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 75.21% 🟢
catalog-lakehouse-generic 61.16% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 86.08% -0.2% 🟢
catalog-lakehouse-paimon 84.29% 🟢
catalog-model 77.99% 🟢
cli 44.62% 🟢
client-java 77.91% 🟢
common 58.29% 🟢
core 84.65% +0.09% 🟢
filesystem-hadoop3 76.48% 🟢
flink 0.0% 🔴
flink-common 53.63% 🟢
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 54.41% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 66.16% 🟢
iceberg-rest-server 77.03% 🟢
idp-basic 86.77% 🟢
integration-test-common 0.0% 🔴
jobs 62.92% 🟢
lance-common 34.02% 🔴
lance-rest-server 69.51% 🟢
lineage 59.39% 🟢
optimizer 83.24% 🟢
optimizer-api 21.95% 🔴
server 90.17% 🟢
server-common 82.0% 🟢
spark 56.37% 🟢
tencent 81.78% 🟢
trino-connector 59.52% 🟢
Files
Module File Coverage
catalog-jdbc-common DataSourceUtils.java 86.21% 🟢
catalog-lakehouse-iceberg IcebergCatalogCapability.java 84.0% 🟢
IcebergCatalog.java 80.0% 🟢
core OccWriteSupport.java 100.0% 🟢
TableMetaService.java 100.0% 🟢
SchemaMetaService.java 99.14% 🟢
TableOperationDispatcher.java 87.83% 🟢
TopicMetaService.java 76.61% 🟢
SchemaOperationDispatcher.java 73.26% 🟢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Subtask] Refuse an import whose StringIdentifier already belongs to another live table/schema/topic

2 participants