yuqi1129 opened a new pull request, #14891:
URL: https://github.com/apache/gravitino/pull/14891

   ### What changes were proposed in this pull request?
   
   Initialize ordinary table ownership using the Gravitino ID captured in the 
create result. In one relational transaction, lock that live table ID and its 
creator, check the active owner with a fresh read at READ_COMMITTED, and insert 
only if still unowned. A deleted table or an existing owner is a successful 
no-op. Principal and storage failures still propagate.
   
   Reuse `RelationUpdate` for the identity condition; do not add methods to 
`JDBCBackend`, `RelationalBackend`, or `SupportsRelationOperations`, or add SQL 
mapper methods or change the schema. Reuse the existing fresh-read helper to 
bypass session-cached owner results while holding the table row lock. Add one 
default `OwnerDispatcher.prepareInitialOwner` method so unsupported 
implementations fail before table creation; its returned writer consumes the 
created ID afterwards. This avoids coupling the hook to `OwnerManager` or 
holding database resources across external catalog calls. Custom owner 
dispatchers/stores must implement equivalent atomic semantics before using 
authorized table creation. Custom table dispatchers must retain the original 
Gravitino ID in the create result; a missing identity is rejected after 
creation.
   
   ### Why are the changes needed?
   
   A late callback for A's table can resolve the same name to C's replacement 
and overwrite C's owner. Checking the ID before a separate name-based write 
leaves the same race. Locking the actual ID together with the owner write also 
preserves concurrent explicit owner transfers.
   
   Fixes #14792
   
   ### Does this PR introduce _any_ user-facing change?
   
   Authorized ordinary table creation no longer assigns ownership to a 
same-name replacement. Explicit owner-transfer APIs, configuration, and REST 
formats are unchanged.
   
   Scope: this fixes the stored owner relation on 
`TableHookDispatcher.createTable`. The other entity and alternate REST create 
paths in #14786 remain outside this PR. Authorization plugin notifications 
retain their existing post-commit, name-based semantics; this does not provide 
a distributed transaction with external catalogs or plugins. Renames retain 
identity: a live, unowned original ID remains eligible regardless of its 
current name. No schema migration is needed; normal upgrades still require 
stopping old instances before starting the new version.
   
   ### How was this patch tested?
   
   Deterministic hook/manager regression for drop and same-name recreation; 
identity snapshots, unsupported implementations before create, cache 
invalidation, callback counts, and failure propagation. Real database lock-wait 
tests cover committed and rolled-back owner writes, table deletion, creator 
deletion, duplicate initialization, and explicit owner transfer on H2, MySQL, 
and PostgreSQL. 174 relevant tests passed across the unit and three database 
lanes; one existing PostgreSQL-only test was skipped in each of the H2 and 
MySQL lanes. Spotless and core Javadoc passed. Temporary mutations restoring 
name-based ownership or bypassing the fresh owner read each make their new 
regression fail; the original sources were restored and the affected tests 
rerun.
   
   The full core suite was not run; the selected tests cover 
`TestOwnerManager`, `TestTableHookDispatcher`, `TestTableEvent`, 
`TestInitialOwnerRequest`, `TestEntityCombinedObject`, 
`TestRelationalEntityStore`, `TestOwnerAssignmentWrites`, 
`TestNormalizedOwnerOperations`, and `TestOwnerMetaService`.
   


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