Repository navigation
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
LGTM after reviewing this from the state-machine, concurrency, and unhappy-path angles.
- correctness: completion is now fenced to the same
RUNNINGrow plus the same runner/attempt, so a late stale worker can no longer overwrite a reaped terminal state - symmetry: MySQL and memory storage now follow the same completion contract, while reaper updates remain intentionally unconditional under the existing task lock
- unhappy path coverage: the new regression proves stale completion preserves
TIMEOUTand does not block the current attempt from completing normally
I did not find a remaining correctness, hang, or state-corruption issue in the latest diff.
Merge Queue Status
This pull request spent 5 minutes 38 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Tick the box to put this pull request back in the merge queue (same as
|
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25604 ## What this PR does / why we need it: A timed-out SQL task run can be reaped while its original worker is still finishing. The old completion path unconditionally updated the row by `run_id`, allowing the late worker to overwrite the terminal `TIMEOUT` state with `SUCCESS` or `FAILED`. This change makes completion a fenced state transition. MySQL only updates a row that is still `RUNNING` and still belongs to the same runner and attempt; the memory storage follows the same contract. Reaper updates remain unconditional so they can continue to mark stale runs atomically under the existing task lock. The shared storage regression test reaps a stale run, verifies that its late completion affects zero rows and preserves `TIMEOUT`, then verifies that the current attempt still completes normally. Tested with: `go test -count=1 ./pkg/taskservice` `go test -race -count=10 ./pkg/taskservice -run '^(TestCompleteSQLTaskRunRejectsReapedRun|TestAcquireAndCompleteSQLTaskRun|TestAcquireAndCompleteSQLTaskRunInSqlMock|TestSQLTaskMySQLStorageErrorBranches)$'` `go vet ./pkg/taskservice` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25604 ## What this PR does / why we need it: A timed-out SQL task run can be reaped while its original worker is still finishing. The old completion path unconditionally updated the row by `run_id`, allowing the late worker to overwrite the terminal `TIMEOUT` state with `SUCCESS` or `FAILED`. This change makes completion a fenced state transition. MySQL only updates a row that is still `RUNNING` and still belongs to the same runner and attempt; the memory storage follows the same contract. Reaper updates remain unconditional so they can continue to mark stale runs atomically under the existing task lock. The shared storage regression test reaps a stale run, verifies that its late completion affects zero rows and preserves `TIMEOUT`, then verifies that the current attempt still completes normally. Tested with: `go test -count=1 ./pkg/taskservice` `go test -race -count=10 ./pkg/taskservice -run '^(TestCompleteSQLTaskRunRejectsReapedRun|TestAcquireAndCompleteSQLTaskRun|TestAcquireAndCompleteSQLTaskRunInSqlMock|TestSQLTaskMySQLStorageErrorBranches)$'` `go vet ./pkg/taskservice` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25604 ## What this PR does / why we need it: A timed-out SQL task run can be reaped while its original worker is still finishing. The old completion path unconditionally updated the row by `run_id`, allowing the late worker to overwrite the terminal `TIMEOUT` state with `SUCCESS` or `FAILED`. This change makes completion a fenced state transition. MySQL only updates a row that is still `RUNNING` and still belongs to the same runner and attempt; the memory storage follows the same contract. Reaper updates remain unconditional so they can continue to mark stale runs atomically under the existing task lock. The shared storage regression test reaps a stale run, verifies that its late completion affects zero rows and preserves `TIMEOUT`, then verifies that the current attempt still completes normally. Tested with: `go test -count=1 ./pkg/taskservice` `go test -race -count=10 ./pkg/taskservice -run '^(TestCompleteSQLTaskRunRejectsReapedRun|TestAcquireAndCompleteSQLTaskRun|TestAcquireAndCompleteSQLTaskRunInSqlMock|TestSQLTaskMySQLStorageErrorBranches)$'` `go vet ./pkg/taskservice` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #25604
What this PR does / why we need it:
A timed-out SQL task run can be reaped while its original worker is still finishing. The old completion path unconditionally updated the row by
run_id, allowing the late worker to overwrite the terminalTIMEOUTstate withSUCCESSorFAILED.This change makes completion a fenced state transition. MySQL only updates a row that is still
RUNNINGand still belongs to the same runner and attempt; the memory storage follows the same contract. Reaper updates remain unconditional so they can continue to mark stale runs atomically under the existing task lock.The shared storage regression test reaps a stale run, verifies that its late completion affects zero rows and preserves
TIMEOUT, then verifies that the current attempt still completes normally.Tested with:
go test -count=1 ./pkg/taskservicego test -race -count=10 ./pkg/taskservice -run '^(TestCompleteSQLTaskRunRejectsReapedRun|TestAcquireAndCompleteSQLTaskRun|TestAcquireAndCompleteSQLTaskRunInSqlMock|TestSQLTaskMySQLStorageErrorBranches)$'go vet ./pkg/taskservice