Skip to content

fix: bound compression scratch growth and oversized merge batches - #32052

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
aptend:fix/merge-row-size-boundary-20261103
Nov 3, 2026
Merged

mergify[bot] merged 6 commits into
matrixorigin:mainfrom
aptend:fix/merge-row-size-boundary-20261103

Conversation

@aptend

@aptend aptend commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #32051

What this PR does / why we need it:

A legal LZ4 scratch request slightly above 1 GiB was rounded to 2 GiB, exceeding mpool's single-allocation limit and panicking. Retain power-of-two growth where it fits; allocate the exact requested size when rounding alone would cross the limit. Actual allocation failures retain the existing panic behavior.

Check the output batch size after every appended row in both sorted merge and reshape. Flush the block and finish the object once its size exceeds 1.5 × target object size (192 MiB for a 128 MiB target), using the existing writer path. Keep the schema row limit and source transfer stride unchanged. The threshold is soft: one indivisible row may exceed it.

Only critical regression coverage is added:

  • Compression capacity at 1 GiB and mpool's allocation boundary, without GiB-sized test allocations.
  • Sorted merge and reshape with skewed rows and a deleted row: persisted values, order, early flushing and transfer destinations.

Validation after rebasing onto upstream main dd2499cdcd (Go 1.27.1, CGO and matching third-party libraries):

  • make static-check-analysis GOLANGCI_LINT_CONCURRENCY=4 — passed on the full package graph, including pinned molint and golangci-lint 2.14.0; 0 issues.
  • license-eye -c .licenserc.yml header check and license-eye -c .licenserc.yml dep check — passed.
  • go test -p 2 ./pkg/objectio ./pkg/vm/engine/tae/mergesort -count=1 — both complete package test suites passed.

Prior A/B benchmark of the per-row check on deployed revision 71498157cc (8 alternating pairs, real merge/writer, memory file service): median time +0.6% for 8 fixed columns, +0.7% for 16 mixed columns, +2.9% for 512 columns. For 4 MiB rows, time fell 20.1% and incremental vector mpool peak fell from 784.7 to 401.9 MiB. A skewed 2 MiB-every-32-rows case was 4.2% faster but allocated 63.8% more cumulative Go bytes, so earlier flushing does not uniformly reduce allocation volume.

@mergify mergify Bot added the kind/bug Something isn't working label Nov 3, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Nov 3, 2026
@aptend
aptend marked this pull request as ready for review November 3, 2026 03:56
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: a06d552a5339470a5b1faa61b9283a09526b1376

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: a06d552a5339470a5b1faa61b9283a09526b1376

Assessment: approve

No actionable findings. Compression sizing and earlier flushing preserve persisted values, ordering and transfer mappings.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Both complete owning-package suites passed, including all new regressions.

  • Base control failed both merge regressions as expected.

  • Preflight, native build, formatting and diff checks passed; receipts and logs reconciled in validation-report.json.

  • Five paired benchmarks measured 3.7–4.6% median component overhead, acceptable for the tighter bounds.

Limitations:

  • Local execution used Linux/amd64. No GiB-sized allocation or production throughput run; component benchmarks had noisy outliers.

@mergify

mergify Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

queue

☑️ Command queue ignored because it is already running from a previous command.

XuPeng-SH pushed a commit that referenced this pull request Nov 3, 2026
…32081)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes #32051

## What this PR does / why we need it:

Backports #32052 to `4.2-dev`.

Avoid an allocator-limit panic when a legal LZ4 scratch request above 1
GiB rounds up to 2 GiB: use the exact request when only power-of-two
growth would exceed mpool.MaxAllocationSize(). Allocation failures
retain the existing panic behavior.

Check output batch bytes after every appended row in sorted merge and
reshape, flushing through the existing writer path when the batch
exceeds 1.5 times the target object size (192 MiB for a 128 MiB target).
Preserve the schema row limit and source transfer stride. One
indivisible row can exceed the soft byte threshold.

The regression fixture uses this branch's existing test host because the
main-branch JSON readback fixture is absent. Coverage remains limited to
the allocation boundary and persisted data/order/transfer mappings for
sorted merge and reshape with skewed and deleted rows.

Validation on Go 1.26.4 with CGO and matching native dependencies:

- `go test -p 4 ./pkg/objectio ./pkg/vm/engine/tae/mergesort -count=1` —
both complete package test suites passed.
- `make static-check` — passed on the full package graph (0 issues);
uses this branch's pinned golangci-lint 2.6.2, molint
v0.0.0-20260602145143-222a0b8adf07 and license-eye 0.4.0.
@mergify

mergify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as d2451d5 at 17:27 UTC

2 h 22 min in the queue, 1 h 8 min of it CI.

So far

  • ✅ Entered the queue Tue 3 Nov, 15:05 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 17:27 · d2451d5 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 8904b29f Deployed Nov 3, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Large-row merges panic when compression buffer growth exceeds mpool allocation limit

3 participants