fix(plan): bound right dedup memory#25936
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? |
f87bde2 to
a48a611
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed against f860ce2.
Verified the full closure of the change:
- RIGHT DEDUP memory accounting matches the executor hash-map type selection, load factors, growth steps, and chained-map coexistence. Unknown/non-finite/overflow estimates conservatively fall back to normal DEDUP.
- The fallback runs before child swapping and is followed by stats/shuffle recomputation, so it does not leave partially converted physical state.
- FLOAT DEDUP keys stay off the runtime hash-shuffle path, which does not support FLOAT.
- Broadcast workers still merge shared matched/capture state; shuffle workers finalize and clean their disjoint partitions independently, including Reset/reuse paths.
Local verification (CGo-transitive wrapper): full and -race tests passed for ./pkg/container/hashtable, ./pkg/sql/colexec/dedupjoin, and ./pkg/sql/plan. git diff --check also passed. No blocking issue found.
|
Follow-up: I also completed real SQL execution against the exact reviewed head Results:
One observed conservative behavior: small or not-yet-flushed target/index tables can still present |
Merge Queue Status
This pull request spent 3 hours 22 minutes 22 seconds in the queue, including 1 hour 5 minutes 1 second running CI. Required conditions to merge
|
|
Follow-up byte-threshold validation on exact head f860ce2 (correcting the earlier row-threshold-only experiment):
This confirms the planner uses the combined resident-map byte estimate and switches the whole chained dedup stage at the exact strict-greater-than memory boundary. I also reran the estimator, combined-map planner, ShouldSpill, and hashbuild memory-threshold spill tests; all passed. Scope note: this validates the OOM-prevention planning decision without intentionally exhausting machine memory; it is not a literal OS-OOM reproduction. |
What type of PR is this?
Which issue(s) this PR fixes:
issue #22151
What this PR does / why we need it:
RIGHT DEDUP builds the target map and then inserts every incoming key while probing. That probe-side growth cannot transition into the current build-side spill engine, so large insert-select statements can retain tens of GiB and OOM a CN.
This PR:
join_spill_memvalues;The default combined budget is approximately one eighth of CN memory after the file-cache reservation. Normal DEDUP hash-shuffles supported keys; FLOAT keys stay unshuffled and spill locally.
Validation:
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/sql/plango build -mod=readonly ./pkg/sql/plango vet -mod=readonly ./pkg/sql/plango build -mod=readonly ./pkg/container/hashtablego vet -mod=readonly ./pkg/container/hashtablego test -count=1 -timeout=120s ./pkg/container/hashtable../mo-tester/run.sh -n -g -p test/distributed/cases/operator/in_range_operator.sql(368/368 passed)Design decision: this selects the already-spillable normal DEDUP implementation for memory-unsafe plans instead of attempting to switch RIGHT DEDUP after it has streamed rows downstream. RIGHT DEDUP remains a small-input optimization; absent/default statistics take the safe fallback. FLOAT shuffle support is intentionally deferred to a separate PR.