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

   ### Describe the subtask
   
   **Managed fileset create is not strict.** 
`FilesetCatalogOperations.createMultipleLocationFileset` does 
`store.exists(...)`, prepares the storage directories, then 
`store.put(filesetEntity, true /* overwrite */)`. Two concurrent creates on two 
servers can both pass the existence check; the second one replaces the first 
one's metadata under the store lock and reports success. The monotonic version 
only orders the overwrite, it does not turn it into "already exists". Every 
other managed create (catalog, managed schema/table/function, model, user, 
group, role) already inserts with `overwrite = false`.
   
   **The boolean is the root cause.** `EntityStore.put(entity, overwrite)` is 
shared by user creates, import-on-read and reconcile. A `true` on a create path 
is exactly how a concurrent winner gets replaced, the upsert behaves 
differently on MySQL (natural-key conflict keeps the old `table_id`) and 
PostgreSQL (`ON CONFLICT (table_id)`), and import and reconcile need different 
id rules from create.
   
   Proposed change:
   - Fileset: `store.put(filesetEntity, false)`; map the duplicate to 
`FilesetAlreadyExistsException`; move `mkdirs` after the store decision or make 
it idempotent and clean the loser's directory.
   - Introduce a write-intent enum — `CREATE` (strict insert), 
`CREATE_IF_ABSENT`, `IMPORT` (id must be free or owned by the same entity), 
`RECONCILE` (observed id/version required) — and route each 
dispatcher/operation through the right one; keep the boolean overload as a 
deprecated adapter for one release.
   - Two-server test: exactly one fileset create succeeds; the loser cannot 
change the winner's metadata.
   
   Design: implementation design Part 2 (M1, M7). Gate G2.
   
   ### 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