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

   ### Describe the subtask
   
   `JobMetaService` has no `updateJob` method — only `insertJob(entity, 
overwrite)`, which calls `insertJobMetaOnDuplicateKeyUpdate`, a raw 
last-writer-wins upsert with no DB-level concurrency check. `JobPO` already has 
unused `currentVersion`/`lastVersion` columns intended for exactly this.
   
   Today `JobManager` compensates manually at each mutation site (`cancelJob`, 
`pullAndUpdateJobStatus`) by taking a coarse `LockType.WRITE` tree lock and 
re-fetching the latest entity inside it before overwriting — a pattern that has 
to be re-implemented correctly at every call site instead of being enforced 
once at the DB layer. This is inconsistent with the sibling `JOB_TEMPLATE` 
entity's `alterJobTemplate`, which uses `entityStore.update(...)` under a 
`LockType.READ` lock because the storage-layer update handles versioning 
transactionally.
   
   **Proposed change:**
   - Add a version-checked `updateJob` to `JobMetaService` (mirroring 
`JobTemplateMetaService`'s versioned update), using 
`JobPO.currentVersion`/`lastVersion`.
   - Wire an `EntityStore.update` path for `JOB` entities.
   - Switch `JobManager.cancelJob` and `pullAndUpdateJobStatus` to use 
`entityStore.update(...)` under a `LockType.READ` lock instead of manual 
re-fetch + `put(overwrite=true)` under `LockType.WRITE`.
   
   ### Parent issue
   
   #12667
   


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