smengcl opened a new pull request, #11321:
URL: https://github.com/apache/ozone/pull/11321

   Generated-by: Claude Code (Opus 5)
   
   ## What changes were proposed in this pull request?
   
   A diff job is stored under `jobKey` (fromSnapshotId + toSnapshotId), but its 
report rows are written under keys prefixed with the job's `jobId`.
   
   Cancellation is cooperative: `cancelSnapshotDiff` flips the status to 
`CANCELLED` without interrupting the executor task. `CANCELLED` is 
resubmittable, so a resubmit creates a new job with a fresh `jobId` under the 
same `jobKey` and sets the status back to `IN_PROGRESS`. The still running task 
of the cancelled job then reaches `updateJobStatusToDone`, whose only guard was 
`status == IN_PROGRESS`, which passes again for the new job. It publishes its 
own entry count and largest entry key against the new `jobId`, whose report 
rows do not exist, so the reader fails `checkReportsIntegrity` on the last 
page. `DONE` is not resubmittable, so the diff the client just recomputed is 
discarded and the job stays unreadable until report retention GC clears it.
   
   Fix: pass the running task's `jobId` to `updateJobStatusToDone` and publish 
only when the stored job still carries it. The check sits inside the already 
`synchronized` method, so it cannot be raced by a concurrent resubmit.
   
   Out of scope here: `updateJobStatusToFailed`, `recordActivity` and 
`updateProgress` are still keyed on `jobKey` alone, and `checkReportsIntegrity` 
passes a `jobId` where `updateJobStatus` expects a `jobKey`.
   
   Found by TLA+ model checking of the OM snapshot diff job state machine, then 
confirmed against these code paths.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-16441
   
   ## How was this patch tested?
   
   New unit test 
`TestSnapshotDiffManager#testUpdateJobStatusToDoneSkipsSupersededJob`: a 
publish carrying a superseded `jobId` leaves the job `IN_PROGRESS`, the live 
job's own publish reaches `DONE`.
   
   Reproducing the race end to end would need the orphaned task parked at its 
publish step across the cancel and resubmit, a rendezvous seam the executor 
path does not have, so the test pins the invariant on the publish method 
directly.
   
   CI on this PR.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to