Repository navigation
fix(dedupjoin): free captured vectors with owner pool - #33133
Conversation
|
This pull request is merged. |
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? |
|
mo-bot review · Commit: discussion changed before publication |
fengttt
left a comment
There was a problem hiding this comment.
Can you please find out the query that caused these bug and add them to BVT? So that BVT will cover this case.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 60d6638a4eef5a077a62da3a446a315c992d1ff2
Assessment: request_changes
DedupJoin now carries the worker’s exact memory pool through the existing mailbox. The ownership checks and a two-row SQL reproduction confirm the fix. Preserve that SQL case in the REPLACE BVT to close the regression coverage gap.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
- P2
pkg/sql/colexec/dedupjoin/join.go:821: A REPLACE into a real primary-key table uses parallel DedupJoin workers that publish captured vectors. The pinned testing contract requires public-path coverage for SQL-visible errors and calls for retaining a practical pre-fix reproduction.
Impact: The new unit test covers pool ownership after the operator is selected. The existing MergeTop REPLACE fixture also passed on the base in the tested configuration, so it does not catch the observed SQL failure there.
Evidence: With optimizer_hints='execType=2' and max_dop=2, the two-row frontend probe returned error 20101 with a vector mpool mismatch on the base. On the PR head it returned two rows, marker sum 31, and marker 21 for key 2. Retain this case in the REPLACE BVT with the same result assertions. See the pinned testing-contract.md sections 1 and 4, and attempt-2 receipts 1795498608950170446-2 and 1795498609250575439-2.
Validation:
-
Recovered both terminal SQL results and matched their overlays, commands, exit codes, and retained logs to the frozen head. The base failed in DedupJoin finalization and the head passed. Logs are attempt-2/replace-parallel-base.jsonl and attempt-2/replace-parallel-head.jsonl.
-
The verified base operator probe reproduced the mismatch during ordinary merge and abort drain. The head passed 100 race repetitions for both paths and the rejected-publication control. Receipts 1795497356333797676-2 and 1795497382428355866-2.
-
Four focused repository tests each passed 100 race repetitions. The DedupJoin race suite passed with the unrelated shuffle re-spill cases excluded. Receipt 1795497534516774401-2.
-
Review plan, validation record, and discussion assessment are saved in model-switch-1795498583242766853.
Limitations:
-
The unfiltered DedupJoin race run reached its test deadline. Receipt 1795497414754024294-2.
-
The SQL probe used a synthetic fixture on one CN. The full production statement and the cause of the coincident admission suspension remain unverified.
|
Thanks, I traced both production statement IDs in the incident logs and matched their SQL to the writer source from the same stability run. The affected statement is a single-row The new The local base reproduction also showed admission suspension after the failed statement, which is consistent with the unfreed allocation reaching terminal account validation. It does not establish the complete production causality, so the PR claims only the confirmed pool-ownership fix. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 47a691fe61df0bce9bab07cea80fe0f0a714de39
Assessment: approve
DedupJoin now carries the allocating worker’s memory pool through the existing mailbox, so merge and abort cleanup release captured vectors with the correct pool. The composite-key REPLACE test closes the prior SQL regression coverage finding.
Model: gpt-6.2-sol / xhigh
Session: 01a20682-9189-75a0-839a-f36d8b2372a5 · slot 1 · generation 3
Validation:
-
The committed REPLACE case passed twice on the same CN in normal mo-tester comparison mode. Both runs passed all 16 statements with zero skips, and a catalog query confirmed database cleanup after each run. Receipt 1795502795964075886-2.
-
The same case reproduced the vector mpool mismatch at REPLACE with the two production files overlaid from the pinned base. Receipt 1795502830963983970-2.
-
Verified the retained race evidence against the unchanged Go sources. Four focused ownership and cancellation tests passed 100 repetitions each, and the relevant DedupJoin race suite passed. Evidence verification receipt 1795502150848804633-2.
Limitations:
-
The unfiltered DedupJoin race run reached its deadline in the shuffle re-spill cases.
-
SQL validation used one embedded CN. The full production statement and the cause of the reported admission suspension remain unverified.
Independent QA challenge — reportAll probes below are newly written for this review; no pre-existing tests were re-run. Verdict: the fix is effective and necessary. No correctness or performance regression found. LGTM. 1. Defect provenance — A/B against PR base parent
|
| Path | Base behavior (asserted by probe) |
|---|---|
| merge-complete free | merger frees worker-owned captured vectors with its own process pool → panic; worker pool accounting wedged in a half-released state |
stopAndDrain (abort/cancel) |
drain panics on the first message; the remaining generation stays queued and unfreed → leak across multiple worker pools |
| merge-error free | a mid-merge failure routes the message into the same foreign-pool free → panic with partial copied state left behind |
The same scenarios pass on PR head: capturedMP follows the message across the mailbox boundary, rejected publishes keep local ownership, and a mismatched message frees its prefix and allows clean re-entry without double-free.
2. White-box on head 47a691fe (new probes only)
- stopAndDrain / reset algebra — 4-participant mailbox, 3 workers publishing from 3 distinct pools → stopAndDrain; full reset algebra; new generation can
trySendagain; every pool returns to itsCurrNBbaseline. - Merge copy failure (destination storage on a foreign pool) — first-column state intact, failed bucket not published as complete, source message and both foreign pools all released back to baselines.
- Malformed message cleanup — mismatch panic releases the prefix, then clean re-entry after repairing the owner pool, no double-free.
- Concurrent receive vs drain race (8 distinct pools, 64 messages) — consumption is exactly-once under receiver-vs-drain races, ctx-cancel and stopped both handled, all 8 pools back to baseline.
-race -count=2: clean.- Perf: carried-owner-pool 5.6–6.6µs/op vs old-style process-pool-lookup control 6.2–6.4µs/op, 0 allocs both ways → no regression from carrying the owner pool.
3. Black-box — full launch-mode cluster built from head (strict mode, 10-way parallel)
All drivers are new SQL scenarios (no BVT reuse): 100k/500k/2M-row sources.
- Correctness: overlap merge run twice (statement/pipeline re-use), disjoint new keys with old rows intact, NULL payloads + long varlena (>24B) through capture across two rounds, intra-batch duplicate keys (keep-last, no torn rows), secondary-unique delete+insert semantics — all exact via two-directional anti-joins (
missing=0 extra=0, row counts exact). - Strict-mode mid-statement failure (varchar overflow): statement aborts atomically, table unchanged, same connection survives and retry succeeds.
- Two concurrent sessions REPLACE into the same 30k keys: both succeed; final rows fully coherent, no mixed-column rows.
- Mid-statement KILL QUERY on a slowed REPLACE: killed session gets
ERROR 1317 context canceled; another session sees 0 rows (uncommitted writes invisible); the same connection re-runs the full 2M REPLACE; digest (count/sum(k)/sum(f)/sum(len)), matches source exactly; server healthy throughout. - Server log scan across the whole run: 0 hits for
vector mpool mismatch|panic|fatal(the only workload-related ERROR lines are the two deliberate failure probes). - Macro perf: full 2M-row REPLACE INTO ≈ 1s on Apple M4 — the capture-pool transfer introduces no observable overhead.
4. Not covered by this pass (for the record)
shuffle/split build path, spill multi-bucket, and ODKU/merge-out variants (covered by the PR's own BVT, deliberately not re-run here). SQL-level cancellation timed exactly inside the finalize window is not deterministically reachable from outside; that window is covered by the white-box receive-vs-drain race probe instead.
Probe sources available on request: zz_qa_33133_test.go (head) / zz_qa_33133_base_test.go (base) / qa33133-blackbox/ SQL drivers.
Resolve conflicts with matrixorigin#33115 (vector test consolidation) and matrixorigin#33127/matrixorigin#33133 (dedupjoin captured-vector owner pool): carry the read-only-NULL fixture to minmax_test.go, keep the pool-owned bitmap tests in mpool_test.go, and free both the captured vectors (with their owner pool) and the worker's matched/captured bitmaps in freeWorkerJoinMsg. Port upstream's new tests to the pool-taking bitmap API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Addresses the observed DedupJoin panic in #33124.
What this PR does / why we need it:)
REPLACE INTODedupJoin capture vectors are allocated through the worker's MPool view. The worker message transferred those vectors without their exact pool, so merger cleanup calledVector.Freewith a different process MPool and panicked withvector mpool mismatch.Carry the originating
capturedMPalongside the vectors and transfer both only after successful mailbox publication. Merger receive, error, cancellation, drain, Reset and Free cleanup now use that pool; unpublished vectors remain owned by the worker.The unit regression exercises worker finalize, mailbox transfer and merger cleanup with separate processes and an allocation account. It reproduces the old mismatch, checks the worker account is released while the merger copy remains live, and verifies both process pool baselines.
The new REPLACE BVT preserves the incident's sanitized SQL shape: one 15-column
VALUESrow into a composite primary key, with the original column type families. It forces parallel execution and asserts affected-row count, full ordered rows, session-setting restoration, and database cleanup. The same BVT reproducesvector mpool mismatchon the PR base and passes twice on the PR head (16/16 statements each run, no skips).Validation: dedupjoin package tests and race tests,
go vet, repository-pinned golangci-lint (0 issues), the base/head SQL BVT comparison, andgit diff --checkpass.The issue also reports admission suspension during the incident, but does not establish that this panic caused it. This PR addresses the observed pool mismatch and makes no claim about that causal link.