Repository navigation
fix(txn): preserve snapshot state on cancellation - #26774
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? |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed d68c908 against main@ab49099c0f487255df131f45c3aecf4a4650fed7.\n\nNo P0–P3 findings. I traced the cancellation path through disttae workspace writes, table lookup, dump/compaction, duplicate checking, and the nested internal-SQL/TN-debug path. SnapshotTS is now published only after the waiter succeeds; lookup error paths restore the workspace lock, and copied batches are cleaned on cancellation. The 25 current checks are complete with no failing conclusions.\n\nLocal focused tests could not start in the isolated worktree because the required native cgo/libmo.dylib artifact is not present; the completed PR CI was used as execution evidence.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed d68c908 against merge base main@ab49099c0f487255df131f45c3aecf4a4650fed7.
No P0-P3 findings. The change closes the relevant state and failure paths: SnapshotTS is published only after either timestamp-waiter variant succeeds; statement cancellation is retained through Delete/workspace write/table resolution/dump/compaction/duplicate checking; table-resolution unlock/relock ownership remains balanced on errors; and rejected writes clean copied batches without workspace mutation. A missing transaction-operation deadline now returns an ordinary error before any TN RPC instead of terminating the CN.
Compatibility/performance: there is no exported API change. The write path adds only constant-time nil/cancellation checks; the account context attachment replaces the previous context allocation, and no new scan, lock, goroutine, retry, or unbounded work is introduced.
Fresh local validation at this head:
- focused regressions passed under race, count=20
- full pkg/txn/client and pkg/vm/engine/disttae tests and race tests passed
- full pkg/sql/colexec/deletion and pkg/sql/compile tests passed
- go list/build/vet passed for all four affected/dependent packages
- PR CI is green and the head is mergeable
Merge Queue Status
This pull request spent 44 minutes 35 seconds in the queue, including 43 minutes 47 seconds running CI. Required conditions to merge
|
Backport #26774 to `4.2-dev`. - Publish a new transaction snapshot only after the timestamp waiter succeeds, so cancellation and waiter errors cannot replace a valid snapshot with `0-0`. - Propagate the statement context through disttae workspace writes, table lookup, dump, compaction, and duplicate checking instead of detaching catalog lookup with a background context. - Return an ordinary invalid-input error when a transaction operation has no context deadline instead of terminating the CN process. - Reject canceled delete operations before workspace mutation and cover the cancellation paths with regression tests. The existing statement rollback contract remains responsible for undoing workspace changes when cancellation arrives after a statement has already started mutating its workspace. This is a clean cherry-pick of commit `d68c9083e9411e55264bc54bc3b88fe1d079396a` from #26774 onto `4.2-dev` at `60283acdd464788cc0a1f91ad3e035dddc9454c4`. Validation: - `go list`, `go build`, and `go vet` for `pkg/txn/client`, `pkg/vm/engine/disttae`, `pkg/sql/colexec/deletion`, and `pkg/sql/compile`. - Full tests for those four packages. - Full race tests for `pkg/txn/client` and `pkg/vm/engine/disttae`. - Four focused cancellation/snapshot regressions under the race detector, each repeated 100 times. - `git diff --check` and pre-push concurrency/unhappy-path self-review. Approved by: @XuPeng-SH
- Publish a new transaction snapshot only after the timestamp waiter succeeds, so cancellation and waiter errors cannot replace a valid snapshot with 0-0. - Propagate the statement context through disttae workspace writes, table lookup, dump, compaction, and duplicate checking instead of detaching catalog lookup with a background context. - Return an ordinary invalid-input error when a transaction operation has no context deadline instead of terminating the CN process. - Reject canceled delete operations before workspace mutation and cover the cancellation paths with regression tests. The existing statement rollback contract remains responsible for undoing workspace changes when cancellation arrives after a statement has already started mutating its workspace. Validation: - Full tests for pkg/txn/client, pkg/vm/engine/disttae, pkg/sql/colexec/deletion, and pkg/sql/compile. - Full race tests for pkg/txn/client and pkg/vm/engine/disttae. - Seven focused race tests, each repeated 100 times. - go build and go vet for all affected and dependent packages. Approved by: @iamlinjunhong, @XuPeng-SH
- Publish a new transaction snapshot only after the timestamp waiter succeeds, so cancellation and waiter errors cannot replace a valid snapshot with 0-0. - Propagate the statement context through disttae workspace writes, table lookup, dump, compaction, and duplicate checking instead of detaching catalog lookup with a background context. - Return an ordinary invalid-input error when a transaction operation has no context deadline instead of terminating the CN process. - Reject canceled delete operations before workspace mutation and cover the cancellation paths with regression tests. The existing statement rollback contract remains responsible for undoing workspace changes when cancellation arrives after a statement has already started mutating its workspace. Validation: - Full tests for pkg/txn/client, pkg/vm/engine/disttae, pkg/sql/colexec/deletion, and pkg/sql/compile. - Full race tests for pkg/txn/client and pkg/vm/engine/disttae. - Seven focused race tests, each repeated 100 times. - go build and go vet for all affected and dependent packages. Approved by: @iamlinjunhong, @XuPeng-SH
- Publish a new transaction snapshot only after the timestamp waiter succeeds, so cancellation and waiter errors cannot replace a valid snapshot with 0-0. - Propagate the statement context through disttae workspace writes, table lookup, dump, compaction, and duplicate checking instead of detaching catalog lookup with a background context. - Return an ordinary invalid-input error when a transaction operation has no context deadline instead of terminating the CN process. - Reject canceled delete operations before workspace mutation and cover the cancellation paths with regression tests. The existing statement rollback contract remains responsible for undoing workspace changes when cancellation arrives after a statement has already started mutating its workspace. Validation: - Full tests for pkg/txn/client, pkg/vm/engine/disttae, pkg/sql/colexec/deletion, and pkg/sql/compile. - Full race tests for pkg/txn/client and pkg/vm/engine/disttae. - Seven focused race tests, each repeated 100 times. - go build and go vet for all affected and dependent packages. Approved by: @iamlinjunhong, @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26767
What this PR does / why we need it:
The existing statement rollback contract remains responsible for undoing workspace changes when cancellation arrives after a statement has already started mutating its workspace.
Validation: