Repository navigation
fix(sql): support distinct-table multi-target updates - #26923
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 592ab075294bf65e1f041e40c1e82318a22938c2 after my previous CHANGES_REQUESTED.
The prior partitioned outer-join blocker is closed at the correct ownership boundary: target activation/row-number selection now happens before partition pruning, and both ordinary partition routing and the old/new partition-key phases consume the same already-filtered batch. The cloned physical contexts disable a second selection/accounting pass. I also checked Reset/Prepare reuse: the retained S3 delegate refreshes its seen-row map, admission callback, and affected-row callback after the old selector state is freed.
The updated multi_update, preinsert, protobuf, compile, and planner suites pass; the new selector/reuse tests pass under race; build and vet pass. Current CI is green.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Correction after completing the current-head resource-ownership audit: one P1 blocker remains in the partitioned S3 path.
PartitionMultiUpdate.selectPartitionTargetRows grows op.raw.ctr.seenTargetRows before partition routing, but it never measures that growth or calls op.raw.admitSeenTargetRowsGrowth. The downstream physical/phase contexts intentionally set DedupByTargetRowID=false, so s3WriterDelegate.append snapshots the map only after the growth and observes a zero delta. The hashmap therefore bypasses CNMemoryThrottler while remaining retained until Reset/Free.
I independently reproduced this at exact head 592ab075294bf65e1f041e40c1e82318a22938c2: selecting one new Rowid grew the map from 0 to 32,856 bytes, while the test throttler acquired 0 bytes.
Please measure/admit the pre-prune selector growth on UpdateWriteS3 (preserving Reset/Free release and error cleanup), or remove this dormant cross-alias state from stage 1. Add a regression that executes the selector-to-admission boundary; varying only Action in the existing selection test does not traverse S3 admission.
aunjgr
left a comment
There was a problem hiding this comment.
P1: Account the pre-prune Rowid selector growth on the partitioned S3 path.
writeTarget now calls selectPartitionTargetRows before routing, and that call inserts into op.raw.ctr.seenTargetRows. For UpdateWriteS3, the later physical contexts deliberately set DedupByTargetRowID=false, so s3WriterDelegate.append takes its seenSizeBefore snapshot after this growth and observes a zero increment. No call to op.raw.admitSeenTargetRowsGrowth exists around the selector, so the retained map can grow without acquiring from CNMemoryThrottler until Reset/Free.
Please measure and admit the selector growth before partition routing (while preserving the existing release path), and add a regression that actually exercises the selector-to-S3-admission boundary; varying the action while calling the selector alone cannot validate that contract.
# Conflicts: # pkg/pb/plan/plan.pb.go
aptend
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 9461356, including the complete prior review history. All previous blockers are closed: same-chunk RowID duplicates are filtered correctly; target selection happens before partition pruning without a second dedup pass; retained S3 selector state is refreshed across Reset/Prepare; selector hashmap growth is admitted through CNMemoryThrottler and released on lifecycle cleanup, with both grant and rejection covered; the temporary scratch files are gone; and the post-merge protobuf output retains both the target-selector fields and upstream fields. Verification passed: affected package tests across moerr, plan/pipeline protobufs, preinsert, multi_update, compile, and planner; plus focused -race tests for selector admission, rejection/release, reset/reuse, partition routing, and within-/cross-batch dedup.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head 9461356, including the complete prior review history and latest selector-admission fixes. No blocking issue found. The previous partition-pruning, same-chunk/cross-batch RowID dedup, Reset/Prepare selector reuse, and partitioned-S3 memory-admission blockers are closed at their ownership boundaries. I also rechecked distinct-target planner isolation, UPDATE IGNORE branches, auto-increment selectors, partition/index and FK/irregular-index routing, remote protocol gating, and Reset/Free cleanup. Full affected-package tests, focused race tests, go vet, protobuf tests, and diff checks pass locally. GitHub has no failed checks; Ubuntu UT and pessimistic standalone BVT are still running under branch protection.
LeftHandCold
left a comment
There was a problem hiding this comment.
Reviewed exact head 9461356, including the previously reported partition-pruning, cross-batch deduplication, S3 reset/reuse, scratch-artifact, and retained-memory concerns. Those paths are closed in this revision.
I traced the stage-1 contract through independent per-target selectors, target-local lazy evaluation, outer-join NULL filtering, UPDATE IGNORE branch splitting, generated/on-update/check/FK/index handling, deterministic locks, partition delete/insert routing, remote protocol v18, S3 memory admission, and Reset/Prepare/Free ownership. Repeated writable aliases are explicitly rejected as documented for stage 2. I found no remaining production-reachable correctness, performance, or lifecycle blocker. Current CI is green; I deliberately did not rerun heavy local UT/BVT.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed exact head 9461356. The partitioned S3 path now measures the shared Rowid selector map before target selection, admits only the new S3-retained growth, and releases the grant during cleanup. The added regression covers grant, rejection, and release; no additional blocker found.
Merge Queue Status
This pull request spent 3 hours 50 minutes 27 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/defines/const.go # pkg/pb/pipeline/pipeline.pb.go
Merge Queue Status
This pull request spent 42 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. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 11 minutes 24 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. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 22 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. Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/defines/const.go # pkg/pb/pipeline/pipeline.pb.go # pkg/pb/plan/plan.pb.go
Merge Queue Status
This pull request spent 2 hours 37 minutes 35 seconds in the queue, including 48 minutes 6 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
fixes #26340
What this PR does / why we need it:
This is stage 1 of the multi-target
UPDATEwork. It establishes the execution and protocol foundation for statements that update distinct physical tables, while explicitly rejecting multiple writable aliases of the same physical table until stage 2 implements their alias-level semantics.This change:
UPDATEstatements through the modernMULTI_UPDATEpath;UPDATE IGNOREand outer joins do not discard rows belonging to another target;Repeated writable aliases of one physical table return a deterministic not-supported error in this stage. A follow-up PR based on this branch will implement alias-level merge, constraint, generated-column, IGNORE, and affected-row semantics.
Validation:
pkg/common/moerr,pkg/pb/plan,pkg/pb/pipeline,pkg/sql/colexec/preinsert,pkg/sql/colexec/multi_update,pkg/sql/compile,pkg/sql/planTestPartitionMultiUpdateResetReleasesWriterswith-race -count=100pkg/sql/colexec/multi_updatewith-raceupdate_multi_target_modernBVT: 163/163 statements passedmake buildmake generate-pbwith stable generated-file hashesgit diff --check