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

   ### What changes were proposed in this pull request?
   
   Makes the Gravitino store's entity **update** path a real 
optimistic-concurrency (version CAS) operation. Three parts:
   
   1. **Always raise `current_version` on update** for every entity that was 
freezing it (metalake, catalog, schema, topic, tag, user, group, role). 
table/view/function already did; fileset/policy stay conditional (they 
version-history on change).
   2. **Slim the `UPDATE ... WHERE`** to `id + current_version + deleted_at` 
for the always-increment entities, dropping the fragile full-row / JSON-byte 
compare. fileset/policy keep the full-row compare (their conditional version 
cannot guard an audit-only concurrent update — proven by an existing OCC test).
   3. **model migration**: `model_meta` had no version columns, so it could not 
do CAS. Adds `current_version`/`last_version` (mysql/postgresql/h2 base schema 
+ 1.3.0->2.0.0 upgrade scripts, `DEFAULT 1`), raises them on `updateModel`, and 
makes a model-version add also bump `current_version` (adding a version 
modifies the model).
   
   ### Why are the changes needed?
   
   Today no entity does a clean version CAS: updates froze the version and 
leaned on a byte-for-byte row compare, which is fragile and, under HA, cannot 
reliably detect concurrent writes. This is the "alter" half of #12166.
   
   Fix: #12166
   
   ### Does this PR introduce _any_ user-facing change?
   
   No API change. A write that loses a concurrent race now matches 0 rows 
(surfaced as the existing update-failure path). Storage: two additive columns 
on `model_meta` (with an upgrade script); no data migration.
   
   ### How was this patch tested?
   
   New unit tests pin post-update version increments across all entities; a 
DB-level CAS test (topic) asserts stale-version -> 0 rows, current -> 1 row + 
bump; a model test asserts insert=1 -> updateModel=2 -> add-version=3. Full 
`storage.relational.*` suite green on H2.
   
   ### Note
   
   This is the **alter** half. A follow-up PR (drop-side version-checked 
soft-delete) will be based on this branch.
   


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