Repository navigation
fix: release opaque aggregate spill state on reuse - #28925
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? |
919c019 to
a0dfd5d
Compare
|
Rebased the feature commit cleanly onto current The red checks in run
These signatures are base/CI lifecycle and setup failures already tracked by |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review 结果(当前 head 74bf487):
未发现 production ownership 路径的 confirmed correctness defect;replacement/reuse、double-free/UAF、error/cancel/retry、growth/accounting 路径均通过审查。
P2:partial-decode cleanup 测试覆盖不足。pkg/sql/colexec/aggexec/allocation_account_test.go:789-794 的 first[:len(first)-1] 只截断 8-byte trailer,两个 opaque state 已在失败前完成 decode,无法检测 partial opaque allocation/decoding 过程中的泄漏。请保留 trailer case,并对三个 family 增加截断第二个 opaque payload 的测试;断言 allocation account 回到 baseline、group count 为零、后续 decode 成功且 terminal cleanup 完整释放。
Exact-head CI 通过;本地 focused test 因 CGo prerequisite/provenance check 在编译前失败,未运行。
aptend
left a comment
There was a problem hiding this comment.
在 exact head 74bf487 上完成 deep review,未发现阻塞问题。重点核对了 reusable spill decode 前的旧 opaque owner 释放、同尺寸/缩小/空记录替换、decode error 的外层 ae.Free() 回收、mobs 指针清零防止 stale result/double free,以及 HLL/approx-percentile/bitmap 在 group spill/reload 下的 allocation-account 闭环。focused aggexec/group 回归在 CGO + 本地 thirdparties 环境下普通模式和 -race 均通过;当前 head 与 current main 的 merge-tree 也无冲突。
|
Tick the box to add this pull request to the merge queue (same as
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Force deep review 结果(当前 head 74bf487):
P2:此前 partial-decode 测试缺口仍未修复。pkg/sql/colexec/aggexec/allocation_account_test.go:789-797 只截断最后 8-byte trailer;两个 opaque payload 在失败前都已完成 decode,因此无法检测 payload 中途失败时的泄漏。
请保留 trailer case,并针对 HLL、approximate percentile、bitmap 三类,在第二个 payload 内部截断且发生 allocation 后失败;断言 explicit Free 前 allocation account 已回到 baseline、group count 为零、后续 decode 成功,最终 cleanup 完整释放。现有 decoder tests 不能证明 replacement/failure/reuse 的组合契约。
审查到的 ownership/accounting、shrinking/nil replacement、retry/cancel/pooling、double-free/UAF/leak/OOM 和 concurrency 路径未发现额外 confirmed production defect。Exact-head required CI 通过;本轮未运行本地测试。
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28853 ## What this PR does / why we need it: Accounted opaque aggregate states (HLL, approximate percentile, and bitmap) are independently allocated through the aggregate allocation account. During spill reload, a reusable `aggState` can replace its physical vectors while overwriting `mobs` entries. The old state, including entries beyond a smaller incoming record, was therefore left owned by the account and caused `allocation account still owns memory` at terminal cleanup. This change releases every previous opaque state before a reusable spill record is decoded, clears all slots, and retains the existing full cleanup path for zero-row, non-reuse, and decode-error exits. The release scan is bounded by one aggregate work unit and does not add work to resident or non-opaque aggregates. Regression coverage exercises same-size replacement, replacement with a smaller record, nil/empty rows, truncated decode failure, and zero-row reset for HLL, approximate percentile, and bitmap states. The group operator test also compares resident and forced-spill results across the supported aggregate families and requires actual reloads for the spill run. ## Test plan - `mo-cgo-test -v -count=1 -timeout=180s -run '^TestAccountedOpaqueSpillStateReplacementReleasesPreviousState$' ./pkg/sql/colexec/aggexec` - `mo-cgo-test -v -count=1 -timeout=180s -run '^TestAccountedSupportedAggregateFamiliesResidentAndSpillMatch$' ./pkg/sql/colexec/group` - `mo-cgo-test -count=1 -timeout=300s ./pkg/sql/colexec/aggexec` - `mo-cgo-test -count=1 -timeout=300s ./pkg/sql/colexec/group` - The same focused tests and owning packages with `-race` - Incremental `gofmt`, `go vet`, `golangci-lint --new-from-rev`, and `git diff --check` The failed checks in run `34938291815` are not caused by this change: the first Ubuntu UT failed while starting the shared embedded cluster before reaching its SQL assertion, the following failures were admission-cascade errors, and coverage failed during the Java 8 setup download before a profile was produced. These are tracked by matrixorigin#28763/matrixorigin#27822 and are not papered over in this PR with sleeps, retries, skipped tests, or timeout inflation.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28853 ## What this PR does / why we need it: Accounted opaque aggregate states (HLL, approximate percentile, and bitmap) are independently allocated through the aggregate allocation account. During spill reload, a reusable `aggState` can replace its physical vectors while overwriting `mobs` entries. The old state, including entries beyond a smaller incoming record, was therefore left owned by the account and caused `allocation account still owns memory` at terminal cleanup. This change releases every previous opaque state before a reusable spill record is decoded, clears all slots, and retains the existing full cleanup path for zero-row, non-reuse, and decode-error exits. The release scan is bounded by one aggregate work unit and does not add work to resident or non-opaque aggregates. Regression coverage exercises same-size replacement, replacement with a smaller record, nil/empty rows, truncated decode failure, and zero-row reset for HLL, approximate percentile, and bitmap states. The group operator test also compares resident and forced-spill results across the supported aggregate families and requires actual reloads for the spill run. ## Test plan - `mo-cgo-test -v -count=1 -timeout=180s -run '^TestAccountedOpaqueSpillStateReplacementReleasesPreviousState$' ./pkg/sql/colexec/aggexec` - `mo-cgo-test -v -count=1 -timeout=180s -run '^TestAccountedSupportedAggregateFamiliesResidentAndSpillMatch$' ./pkg/sql/colexec/group` - `mo-cgo-test -count=1 -timeout=300s ./pkg/sql/colexec/aggexec` - `mo-cgo-test -count=1 -timeout=300s ./pkg/sql/colexec/group` - The same focused tests and owning packages with `-race` - Incremental `gofmt`, `go vet`, `golangci-lint --new-from-rev`, and `git diff --check` The failed checks in run `34938291815` are not caused by this change: the first Ubuntu UT failed while starting the shared embedded cluster before reaching its SQL assertion, the following failures were admission-cascade errors, and coverage failed during the Java 8 setup download before a profile was produced. These are tracked by matrixorigin#28763/matrixorigin#27822 and are not papered over in this PR with sleeps, retries, skipped tests, or timeout inflation.
What type of PR is this?
Which issue(s) this PR fixes:
issue #28853
What this PR does / why we need it:
Accounted opaque aggregate states (HLL, approximate percentile, and bitmap)
are independently allocated through the aggregate allocation account. During
spill reload, a reusable
aggStatecan replace its physical vectors whileoverwriting
mobsentries. The old state, including entries beyond a smallerincoming record, was therefore left owned by the account and caused
allocation account still owns memoryat terminal cleanup.This change releases every previous opaque state before a reusable spill record
is decoded, clears all slots, and retains the existing full cleanup path for
zero-row, non-reuse, and decode-error exits. The release scan is bounded by one
aggregate work unit and does not add work to resident or non-opaque aggregates.
Regression coverage exercises same-size replacement, replacement with a
smaller record, nil/empty rows, truncated decode failure, and zero-row reset for
HLL, approximate percentile, and bitmap states. The group operator test also
compares resident and forced-spill results across the supported aggregate
families and requires actual reloads for the spill run.
Test plan
mo-cgo-test -v -count=1 -timeout=180s -run '^TestAccountedOpaqueSpillStateReplacementReleasesPreviousState$' ./pkg/sql/colexec/aggexecmo-cgo-test -v -count=1 -timeout=180s -run '^TestAccountedSupportedAggregateFamiliesResidentAndSpillMatch$' ./pkg/sql/colexec/groupmo-cgo-test -count=1 -timeout=300s ./pkg/sql/colexec/aggexecmo-cgo-test -count=1 -timeout=300s ./pkg/sql/colexec/group-racegofmt,go vet,golangci-lint --new-from-rev, andgit diff --checkThe failed checks in run
34938291815are not caused by this change: the first Ubuntu UT failed whilestarting the shared embedded cluster before reaching its SQL assertion, the
following failures were admission-cascade errors, and coverage failed during
the Java 8 setup download before a profile was produced. These are tracked by
#28763/#27822 and are not papered over in this PR with sleeps, retries, skipped
tests, or timeout inflation.