Repository navigation
feat: support bounded exact distinct-key spill - #28003
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? |
Match mo-tester command parsing by removing SQL continuation indentation from the expected result file. The parser trims source command lines before matching, so preserving display indentation prevented the nested DISTINCT oracle and every following command from loading.
…ed-distinct-spill
aptend
left a comment
There was a problem hiding this comment.
Deep re-review completed on exact head 5e2aee6 against exact base 9f711e2. I read the complete review, inline-comment, reply, and thread history; compared the increment since my prior reviewed head 5208b1d; and rechecked the complete PR diff.
The prior multi-chunk recovery blocker is closed. BeginArgumentDrain is allocation-free, and commit/rehome now allocate, swap, and release one aggregate-state chunk at a time, so spill hash scratch no longer overlaps a replacement set proportional to chunk count. Exact Group and MergeGroup regressions span three disjoint 8,192-group chunks under a 2 MiB hard account. I also rechecked terminal errors and cleanup: a mid-commit capacity failure remains terminal and outer operator cleanup owns all partially replaced and unreplaced state; no retry can publish a partial result.
The prior BVT parser blocker is also closed by ef34513. Using the repository mo-tester parser check, the old exact head 95105e3 deterministically reproduces the CI line-38 missing-result error, while this exact head parses the same BVT file successfully. The current exact-head CI rerun is still in progress, so this approval relies on that direct old/new parser proof rather than claiming a completed CI result.
Validation on this exact production revision: make thirdparties; full aggexec, Group, and compile package tests; focused hard-account, continuation, contribution, lifecycle, and multi-chunk race tests at 10 repetitions; go vet for the owning packages; the low-NDV/no-spill and combined-spill benchmark paths; the mo-tester structural check; and git diff --check. All passed. The combined benchmark preserved one read per contribution record at the exercised level.
I independently approve design v2 in docs/design/bounded_exact_distinct_spill.md on this exact revision. Its ownership, bounded resident/disk/FD work sets, synchronous cancellation behavior, terminal-leaf continuation, exact equality, contribution routing, cleanup ordering, compatibility, observability, and validation contracts match the implementation and tested unhappy paths. No blocking correctness, lifecycle, bounded-progress, or acceptance issue remains in the reviewed diff.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review completed on exact head f8071f2d1a9d8a7080993578cc00b92d4f866e5d.
I rechecked the complete change/risk map, prior blocking reviews, the delta from independently approved production/design revision 5e2aee62be147a42b7eef540f7f3544ee579c42e, and the current exact-head CI. The production implementation and design are unchanged since that approved revision; the only feature-file delta is the table-function alias correction in the public BVT.
The prior terminal-leaf, contribution reread amplification, final contribution allocation, multi-chunk hard-account, and BVT parser blockers are closed. Focused Group/aggexec tests and race tests covering ownership transfer, cancellation, terminal-leaf continuation, recursive contribution routing, Group/MergeGroup multi-chunk hard-account completion, NULL/multi-argument semantics, signed zero, and resource cleanup pass locally. Exact-head CI is green.
I also ran the same low-NDV/no-spill benchmark against the PR base and head: the base measured about 460.7 us/op versus 456.1 us/op at head, with effectively unchanged allocation count and no spill-controller activation. No material normal-path regression was observed.
No blocking correctness, boundedness, lifecycle, performance, compatibility, or acceptance issue remains.
Merge Queue Status
This pull request spent 21 minutes 42 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28003 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #27698
What this PR does / why we need it:
Exact saved-argument
COUNT(DISTINCT ...)currently retains one key perdistinct value in
aggState.argSkl. Generic Group spill partitions by thegroup hash, so it cannot subdivide the keys of one high-NDV hot group; reload
must reconstruct that complete set.
This PR adds a Group-owned bounded exact-key spill path while preserving the
existing skiplist normal path for low NDV:
has been flushed and published;
external merge-sort when H0 or a proven single group cannot make hash
progress;
composes them exactly once with recursive generic Group spill;
intermediate Group/MergeGroup boundaries;
zero equality, and exact full-key collision checks; and
repeated-execution ownership paths.
Version 1 deliberately applies only to exact saved-argument
COUNT(DISTINCT ...). Other DISTINCT aggregate families retain their existingbehavior until their reducer, ordering, overflow, and partial-state contracts
are designed.
Design:
docs/design/bounded_exact_distinct_spill.mdValidation:
pkg/sql/colexec/aggexec,pkg/sql/colexec/group, andpkg/sql/compileunit suites;-race;and cross-worker MergeGroup cases 100 times under
-race;payload;
make build;COUNT(*) = 300andCOUNT(DISTINCT result) = 300; andupstream/main.Fixes #27698