Repository navigation
perf(shuffle): balance complete string-key ownership - #27744
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? |
47fcdfe to
ab35c60
Compare
|
@gouhongshen The requested changes are addressed in head P0 closure:
P2 closure:
Regression matrix added for legacy/new round trips, mixed service runtimes, old-field defaults, unknown algorithm values, child/reuse generations, prepared reset, retry inheritance, string/numeric/range markers, both mismatch directions, illegal stable-range metadata, operator duplication, GROUP/join construction type classification, and deterministic equal-key counterexamples. The prior UT failure was separate: under Coverage is non-decreasing for every affected package. The new protobuf wire branches were explicitly checked too: Please re-review the new head. |
aptend
left a comment
There was a problem hiding this comment.
Re-reviewed exact head c692ab6. I read the complete review/comment history and author closure response, audited the full base diff and the increment from the previously reviewed 26c0c91 head. The prior split-brain blocker is closed: the coordinator freezes one mapping generation, child/reused/retry/remote processes inherit it, pre-v33 receivers reject the appended string-hash opcode, and new receivers validate opcode/ProcessInfo agreement before execution. The duplicated row/constant implementation is also unified. I checked complete-key hashing, string type classification, constant/null/expression/vector paths, prepared reset and retry lifecycles, mixed rollout/rollback behavior, numeric/range/IVF boundaries, generated wire fields, and the test-only heartbeat adjustment; no blocking issue remains. Full owning-package tests passed on this exact worktree, as did focused race repetitions across hashtable, pipeline codec, process propagation, shuffle, plan, and compile; diff check is clean.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
All prior blockers remain fixed at the new head, and the incremental delta is a verified safe narrowing of the rollout guard. No blocking or non-blocking findings.
Prior blocker dispositions (revalidated at c692ab6):
- My P0 (per-CN protocol gate allowed one distributed query to hash the same string key to different owners across CNs, silent wrong results) stays FIXED by the freeze mechanism: the owner algorithm is decided once per execution at admission, frozen on Process, propagated to every child/reused/retry process and to remote CNs via ProcessInfo field 16 (strict decode validation), and the ShuffleStable wire opcode makes pre-v33 receivers fail before execution while new receivers cross-check marker vs carried algorithm. All of this is intact at the new head.
- My P2 (two spellings of the owner mapping) stays FIXED: all string-hash call sites route through the single stringHashToRange/appendStringHashSels helpers.
XuPeng-SH's review raised the same P0-class issue and remains addressed by the same mechanism; not re-raised.
New delta review (9895280..c692ab6):
- Merge 135ef97 is a clean merge of upstream #27493 with zero conflict-resolution delta (verified via remerge-diff); those frontend/plan changes are not authored by this PR.
- ed25d52 scopes the ShuffleStable marker to string-key hash shuffles only, via a new Shuffle.StringHashKey flag set from the actual key type in both constructors, copied in dupOperatorWithContext, and carried on the wire as Shuffle.string_hash_key field 11. I verified completeness: all four shuffle construction sites handle the flag; the runtime string-hash path is reachable only for char/varchar/text, exactly matching isStringShuffleKeyType; the planner enables hash shuffle only for plain columns (group) and column/serial_full/serial keys (join), and serial/serial_full are typed varchar so expression-based string shuffles are marked too. Numeric hash shuffles and range shuffles correctly carry no marker, and their routing is algorithm-independent on both sides. Net effect: integer-key shuffles keep working on pre-v33 CNs during a mixed window while string-key shuffles still fail loudly — a strict narrowing of the failure surface with no new correctness gap.
- c692ab6 adds pb-level wire round-trip contract tests for both new fields.
Validation at the new head: pkg/pb/pipeline, pkg/sql/colexec/shuffle, pkg/vm/process pass; pkg/sql/compile passes except the three parquet extern-scan fanout tests already proven pre-existing by identical failures at the clean merge base; the new tests (construction type matrix incl. binary->false, wire contract incl. numeric-hash no-marker case, dup propagation, mixed-runtime admission) pass explicitly; go vet clean on all touched packages.
|
Tick the box to add this pull request to the merge queue (same as
|
What changed
This PR fixes the string-shuffle ownership half of #27728.
Process, copy it to every child/reused scope, and carry it to remote CNs inProcessInfo.ProcessInfoselect the same mapping. Mixed rollout/rollback can therefore fail loudly, but cannot silently split equal keys across owners.Resetstarts a new execution generation and selects again from the rollout gate.-race: test-mode heartbeat RPCs use a 15s budget inside the existing 60s store-liveness window. Product defaults are unchanged, explicit test overrides are preserved, and retry opportunities remain bounded.The implementation is generic: there are no query-text, schema-name, URL-shape, data-size, benchmark, or issue-number branches.
Correctness and rollout contract
InvalidStatebefore operator executionEqual logical keys therefore have one owner for both GROUP and shuffle-join paths. Empty, short, UTF-8, binary-content text, const vectors, and nulls are covered. Unknown algorithm values fail during Process decoding rather than falling back.
Numeric ownership, Range Shuffle, non-shuffle plans, and IVF-FLAT ownership are unchanged. The IVF path continues to use its existing full ObjectID
xxhashmapping.Validation
Validated after merging current
main:pkg/container/hashtable,pkg/pb/pipeline,pkg/sql/plan,pkg/sql/colexec/shuffle,pkg/vm/process,pkg/vm,pkg/sql/compile, andpkg/embed;-race -count=10: complete/legacy hashing, mixed service-runtime admission, ProcessInfo codec, child/reuse generations, retry/prepared reset, string/numeric/range wire markers, marker/metadata mismatch rejection, and operator duplication;pkg/tests/issues -racewithGOMAXPROCS=8, covering the catalog/restore/authenticated shared-cluster combination that failed the previous UT job;Exact statement coverage is non-decreasing for every affected package, including generated wire-code branches:
Performance boundary
The complete-key implementation allocates zero bytes per operation. It is linear in total key bytes by design; an adaptive sampled fallback would recreate data-dependent skew cliffs. Local microbenchmarks measure about 35-36 GB/s for 64 KiB and 1 MiB keys. Ordinary 8-32 byte keys are at least as fast as the legacy helper; 64-byte keys are about 10% slower in the isolated hash loop.
On host
10.222.1.55, using the existing 10,000,000-row / 10,000,000-NDV URL data on NVMe with 16-way execution, twelve interleaved legacy/complete pairs measured:timeConsumedfalls from 8,973ms to 7,350ms;Hash reuse across operators is tracked separately in #27753. Stale post-
ANALYZEplan visibility is also independent of this PR.Part of #27728
Related: #27685, #27753