Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
Release tag v4.1.4-hotfix-20260831 (no same-named remote branch at investigation time).
Commit ID
Other Environment Information
- Local reproduction: macOS arm64, Go 1.26.4, CGO enabled.
- Native library built from the release tag's C sources.
- This is a source/operator reproduction; no claim of a new production load test or RSS measurement.
Actual Behavior
MergeOrder duplicates off-heap input batches into its in-memory merge list. After copying all rows to the independent output buffer, removeInMemoryBatch removes the heap item and frees separately owned sorting columns, but sets batchList[index] = nil without cleaning the input batch. Reset/Free cannot find that batch afterward, so its C-allocated vector data/varlen areas remain allocated.
A four-row/two-input native-vector regression through real vm.Exec returns the correct sorted keys and VARCHAR payloads, but retains 872 native bytes where only 600 bytes belong to the still-owned original inputs and output buffer: 272 bytes are leaked. Both column-key and computed-key variants fail the native accounting assertion; the single-input ownership-transfer control passes.
Expected Behavior
After the final row has been copied, release the consumed input batch exactly once before dropping its owning reference. Keep the output and any still-active inputs valid. Reset/Free should release their remaining resources without leaks or double-free.
Steps to Reproduce
- Create two native batches with ascending key runs
[1,3]and[2,4], each carrying a distinct non-inline VARCHAR payload. - Feed them through the existing mock child into the real
MergeOrderoperator, with spilling disabled for this small input. - Drain using
vm.Exec; validate the merged keys/payloads. - Before Reset/Free, compare
proc.Mp().CurrNB()with original-input native bytes plusctr.buf.Allocated(). - At the above tag the comparison fails by 272 bytes. Heap-backed fixtures do not detect this because this release's
CurrNBtracks off-heap allocations.
Additional information
The missing cleanup belongs after heap removal and order-column membership/free checks, before clearing the batch-list slot. The single-input direct-transfer and disk-spill paths are separate and should remain unchanged. A minimal fix and regression tests are being prepared for the requested hotfix release.
Activity