Repository navigation
fix: make aggregate states version compatible - #28885
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 medium deep review at exact head 81d586d.
Local decision: BLOCKED (COMMENT ONLY).
P1 — upgrading breaks incremental aggregation of persisted HLL sketches. Before upgrade, a non-empty HLL_ADD_AGG(user_id) result can be persisted as version 2. After upgrade, the same producer creates version 3, including for integer inputs. HLL_MERGE_AGG adopts the first non-empty version and rejects the other with incompatible HLL hash versions, so the existing daily-rollup path (see test/distributed/cases/function/func_hll.sql) fails when it appends post-upgrade data and merges old plus new sketches.
The version transition needs an explicit compatibility/upgrade path before changing the default producer. Please add a regression covering base-produced sketch -> upgrade -> append -> merge, including an integer control, and document or implement the transition for existing persisted sketches. The current HLL/CI coverage does not prove this upgrade path; upgrade compatibility jobs were skipped.
No APPROVE/REQUEST_CHANGES action is possible on an author-owned PR; this is the COMMENT-only review result.
aptend
left a comment
There was a problem hiding this comment.
Deep review at exact head 81d586d0db73750fc0d831a4e33793acc5f2f8b7: REQUEST_CHANGES.
I independently reproduced two correctness blockers below. The CGo-aware package suite passed for aggexec, group, compile, plan/function, and datasync; focused aggregate/compile race tests and TestLoopWork/valid_entries race repetitions also passed. Those results do not exercise persisted-state upgrade compatibility, and the PR CI shows both upgrade-compatibility jobs skipped.
The bitmap bounds/error propagation, approximate-percentile ordering/direction and legacy remote gating, ordered-percentile comparator changes, and datasync synchronization otherwise look sound in the reviewed paths.
Separately, this PR body does not follow the repository's current .github/PULL_REQUEST_TEMPLATE.md; please restore the type checklist, issue section, and what/why section when updating it.
| hllHeaderSize = 8 | ||
| hllEncodedSize = hllHeaderSize + hllRegisterCnt | ||
| hllLegacyVersion = byte(2) | ||
| hllVersion = byte(3) |
There was a problem hiding this comment.
[P1] Preserve persisted HLL states across the v2→v3 transition
Changing the default producer to v3 makes every newly produced non-empty sketch v3, including integer inputs whose hashing/registers are unchanged, while useWireVersion rejects any non-empty v2/v3 pair. This breaks the supported persisted-rollup pattern already exercised by test/distributed/cases/function/func_hll.sql: create/store a non-empty HLL_ADD_AGG(user_id) row on the old build (v2), upgrade, append another row from the same integer producer (now v3), then run HLL_CARDINALITY(HLL_MERGE_AGG(sketch)); the query fails with incompatible HLL hash versions: destination 2, input 3 instead of merging the rollup. I reproduced exactly that producer→persist→upgrade→append→merge flow at this head. The MORPC gate only protects live remote states, not blobs already stored in user tables. Please provide an explicit compatible transition/migration path before changing the default producer and cover the persisted upgrade flow with an integer control.
| return | ||
| } | ||
| case types.T_float64: | ||
| decoded := types.DecodeFixed[float64](value) |
There was a problem hiding this comment.
[P1] Canonicalize NaN peers as well as signed zero
The new type-aware path canonicalizes only values equal to zero. MatrixOne's float contract treats all NaN sign/payload encodings as peers (Float64OrderAscCompare returns 0), and SQL can construct different payloads with BIT_CAST. At this exact head, feeding 0x7ff8000000000000 and 0x7ff8000000000001 to APPROX_COUNT_DISTINCT(DOUBLE) returns 2 even though the comparator says they are one SQL equivalence class; the same raw-byte hashing affects HLL_ADD_AGG. A SQL reproducer can insert the two payloads using the existing bit_cast(unhex(... ) as double) pattern from float_nan_order.sql and compare COUNT(DISTINCT x) with both HLL results. This also leaves the NaN-payload regression explicitly requested by #28856 uncovered. Please normalize every NaN to a stable representation for both float widths before hashing and add aggregate/BVT coverage.
81d586d to
1eb8455
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 medium deep review at exact head 1948060\n\nPASS — no blocking findings across correctness, concurrency/lifecycle, liveness, resource bounds, compatibility, and test closures. Persisted HLL remains v2 compatible; DISTINCT representative and spill/recovery paths are consistent. Exact-head CI passed, and the four SQL regressions passed 8/8, 5/5, 9/9, and 10/10 assertions. Upgrade jobs were skipped and excluded from evidence. COMMENT only because this PR is self-authored.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review 发现一个 P1(当前 head 18dd061):
MORPC v74 已被 base 用于 HEX,但本 PR 在 v74 打开了与旧 reader 不兼容的 aggregate 行为。pkg/sql/colexec/group/helper.go:1947 附近:HLL payload 改为 v3,而 base reader 仍拒绝该格式(整数输入也会失败);新的 percentile ordering 也让旧 reader 拒绝 [1, NaN] extrema,并可能把远程 finalization 的 p0 从 NaN 改为 1。针对 v74 的 focused local regressions 失败,v73 对照通过;现有 CI 虽绿,但两个 upgrade job 被 skip。
请保持 v74 的旧 aggregate 行为,改用未占用的 capability version,并用真实 base reader 的 producer/consumer compatibility tests 对齐 gate。自有 PR 按规则只提交 COMMENT。
|
Addressed the P1 found on head
Official CI is pending; upgrade jobs remain skipped and are not counted as green evidence. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review 结果(当前 head 92b4f8d):
此前 v74 HLL/percentile 兼容性 P1 已修复:v74 保持 HLL v2 和旧 percentile ordering,新 capability 从 v75/v76 开始。
仍有 P2:pkg/sql/colexec/aggexec/aggState.go:2797 的 fixed index 在达到 1,024 groups 后 canonicalize FLOAT64 NaN,但 writer 没保留原始 representative。v74 coordinator 合并 upgraded/base worker partial 时,同一个 noncanonical NaN 可能作为两个不同 key 被计数;v78 opaque-DISTINCT gate 不覆盖该路径。请对旧 coordinator 保持 legacy float key(含 fixed-index 和 spill),并用 pinned-base reader、>=1024 groups、noncanonical NaN 的 old/new partial 回归验证。
Exact-head CI 通过,但 upgrade jobs skipped;该 finding 为 source-traced,尚未本地复现。
|
Rebased the PR onto current
Official CI for the new head is now running/pending. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Force deep review 结果(当前 head ac8d361):
此前 DISTINCT NaN 跨版本兼容 P2 仍未修复。pkg/sql/colexec/aggexec/aggState.go:2797 canonicalize FLOAT64 NaN,fixed-index writer 在 line 374 输出该 key 但不保留 raw representative。达到 >=1,024 groups 后,升级 worker 与 base worker 处理同一个 noncanonical NaN 时,v74 coordinator 可能收到不同 key,按 raw bytes 比较后将同一值计数为 2 而不是 1;v78 opaque-DISTINCT gate 不覆盖 fixed-width path。
请对旧 coordinator 保持 legacy float-key semantics,覆盖 fixed-index 及 spill/recovery,并增加 pinned-base reader 的 mixed old/new partial 回归:>=1,024 groups + noncanonical NaN。
此前 HLL/percentile capability collision 已修复:v74 保留 legacy behavior,新 gate 从 v75/v76 开始。当前 CI pending,upgrade compatibility jobs skipped;本 finding 为 source-traced,尚未本地复现。
|
Addressed the fixed-index FLOAT DISTINCT compatibility blocker from the previous review. Current head:
Validation on the exact head:
Official CI is pending. Please re-review the current head; no approval is being asserted from the author side. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Force deep review 结果(当前 head f4691bf):
此前 DISTINCT NaN mixed-version P2 在源码和测试中看起来已修复:aggState.go:3076-3140 在 legacy mode 保留非零 float bits(含 fixed-index key),group/exec2.go:123 在 admission 前选择 policy,spill constructors 继续传播;count2_review_test.go:163 覆盖 >=1,024 groups、noncanonical NaN wire bits、partial merge 和 spill recovery。
协议版本冲突也已修复:defines/const.go:113-118 保留 v75,并将 aggregate capabilities 分配到 v76-v79,producer/planner gates 一致。
仍需补 pinned-base old/new mixed-reader regression;当前 regression 使用 current-code readers,不能单独证明旧 reader 互操作。CI 当时仍 pending,upgrade jobs skipped。暂未发现新的 code defect,建议待上述证据和 exact-head CI 完成后再 merge。自有 PR按规则提交 COMMENT。
|
Updated head: The prior SCA failure was the unused Post-rebase focused aggregate/group/compile tests, legacy/modern fixed-index + spill/restore + cross-representation merge tests, and changed-package golangci-lint (0 issues) pass. I also validated the final producer wire with a reader pinned to base |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Astra medium deep review at exact head 948403b. COMMENT ONLY (self-authored PR).\n\nNo confirmed P0/P1/P2 or code blocker. Reviewed legacy/modern aggregate-state behavior, FLOAT/NaN canonicalization, spill serialization/restore, fixed<->skiplist merge and capacity admission, capability gates, decoder failure cleanup, drain/abort/rehome, and operator teardown. No confirmed leak, double cleanup, new unbounded wait, policy loss, or flaky timing mechanism.\n\nExact-head CI: Ubuntu race UT, coverage UT, Linux/arm64 SCA, shared build, and enabled multi-CN BVTs passed; changed-code coverage 261/323 = 80.80%. Tests use explicit inputs/gate transitions without sleeps.\n\nResidual validation note: mixed-version upgrade jobs were skipped, so a real old-binary/new-binary rollout smoke test remains advisable.
What type of PR is this?
Which issue(s) this PR fixes:
issue #28778
issue #28854
issue #28864
issue #28865
What this PR does / why we need it:
intermediate output, spill, restore, repartition, and partial recovery.
COUNT(DISTINCT ...)FLOAT32/FLOAT64 equality consistent acrossfixed-index, skiplist, merge, restore, and spill paths. Modern state
canonicalizes NaN payloads; legacy remote state retains the old bit-pattern
contract until the protocol capability is available.
would otherwise misinterpret its canonicalized keys.
no protocol threshold or coverage exclusion was changed.
Root cause of the CI failure
The aggregate implementation tests passed, but the PR coverage gate measured
148/211 = 70.14%changed lines, below the required 75%. The missing coveragewas in newly added FLOAT32/FLOAT64 compatibility branches, tuple normalization,
cross-representation merge preflight, policy freezing, and the real Group
partial-output downgrade guard.
This update adds behavior-focused tests for those paths. It does not lower the
threshold, add an ignore rule, or create unreachable code only for coverage.
Validation
main=8e90e412647eee460772068efa127daa23d09828.go test -count=1 -coverprofile=... ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group ./pkg/sql/compile— PASS.aggexec 80.7%,group 82.0%,compile 66.8%.origin/main...HEADdiff,the collected UT/BVT profiles, and the current affected-package profile:
198/224 = 88.39%— PASS (threshold>75%).gofmtandgit diff --check— PASS.fresh producer set, will still run for the pushed head; it is not claimed as
passed here.
No new BVT or full slow UT was added.