Skip to content

fix(vector): return append rollback failures instead of panicking - #32167

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aunjgr:fix/allocator-rollback-errors
Nov 4, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aunjgr:fix/allocator-rollback-errors

Conversation

@aunjgr

@aunjgr aunjgr commented Nov 4, 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:

Related to issue #32143. This contains allocation-error handling; it does not make oversized allocations succeed.

What this PR does / why we need it:

An allocation refusal must remain a returned query error, even when append cleanup cannot restore its checkpoint. RollbackAppend currently panics on invalid checkpoint bounds or missing restoration metadata, which can replace the original allocation error during failure cleanup.

Make RollbackAppend return a terminal allocation-invariant error instead of panicking. Validate restoration bounds and attempted-row arithmetic before mutation, and retain owned capacity for eventual Free. Preserve the original error object unchanged when rollback succeeds; retain both causes when rollback fails so invariant failures cannot be treated as retryable memory pressure.

Update every production rollback caller to propagate the result, including retained join batches, MergeTop, Order, multi-update, JSON conversion and Parquet readers. Continue restoring other affected columns after a rollback failure, and avoid publishing restored batch row counts when rollback did not succeed.

Keep the allocator ceiling, join row addressing and query memory budgets unchanged. Add small CPU regression tests for invalid checkpoints, metadata validation, row-range overflow, allocator-limit refusal, prefix preservation and balanced cleanup.

Validate checkpoint bounds, row-range arithmetic and metadata sidecars before mutating rollback state. Return a non-retryable allocation invariant error instead of panicking, and propagate rollback failures through every production caller while preserving the original error identity after successful rollback.

Keep the allocator ceiling unchanged. Cover invalid checkpoints and small injected allocator-limit failures, prefix preservation and cleanup without big-data verification.
@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 →

@aunjgr

aunjgr commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Validation: CPU unit tests passed for vector, retained-batch append, MergeTop, Order, JSON conversion, multi-update and Parquet callers. The full main-branch static gate passed. Regression tests use small injected allocation limits and invalid checkpoints; no big-data verification was run. The allocator ceiling is unchanged, so this is panic/error-path containment rather than support for allocations above the existing limit.

@XuPeng-SH

XuPeng-SH commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 63c40a5238f864efc4065f70c32564f74e7e4dd6

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: 63c40a5238f864efc4065f70c32564f74e7e4dd6

Assessment: approve

Rollback validation now returns terminal invariant errors before mutation, while successful cleanup preserves the original append error object. All production callers propagate rollback failures, continue necessary column cleanup and avoid publishing restored row counts after failure. The fix reuses the existing checkpoint, ownership and error-classification mechanisms. No actionable correctness, design or required-validation gap remains.

Model: gpt-6.1-sol / max

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

Validation:

  • Reviewed every changed hunk in all nine files, the complete indexed discussion and linked issue #32143; distinguished rollback-error containment from the separate oversized-HashBuild segmentation request.

  • Traced all 33 production RollbackAppend calls, allocation retry classification, metadata ownership, borrowed-vector materialization, row/page publication and terminal cleanup across retained batches, sorting, multi-update, JSON and Parquet consumers.

  • Reused supplied exact-head SUCCESS conclusions for shared build, UT, arm64 SCA, UT coverage, proxy/pessimistic compose BVT and CI Required. Assessed the author's CPU-package validation report as attributed evidence; skipped/neutral lanes were not counted as passes.

  • Local bounded frozen-source audit passed: exact clean HEAD, complete nine-file coverage, supplied patch match, git diff --check, every production rollback caller consuming the error, invariant-before-capacity classification and complete discussion-key coverage. See frozen-audit.log, rollback-callers.json and the matching receipt in validation-audit.json.

Limitations:

  • No local Go/native or SQL execution was performed; the supplied snapshot provides CI conclusions without raw logs, and local_validation is empty.

  • This PR retains the existing allocator ceiling. It does not resolve or validate processing a single HashBuild varlen area above that limit.

@mergify mergify Bot added the queued label Nov 4, 2026
@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 948cfbc at 17:59 UTC

3 h 27 min in the queue, 1 h 5 min of it CI.

So far

  • ✅ Entered the queue Wed 4 Nov, 14:32 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 17:59 · 948cfbc · 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

@mergify
mergify Bot merged commit 948cfbc into matrixorigin:main Nov 4, 2026
@mergify mergify Bot removed the queued label Nov 4, 2026
XuPeng-SH pushed a commit that referenced this pull request Nov 4, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to #32143. Backport of #32167 to `4.2-dev`; this handles
allocation-error cleanup, not oversized allocation support.

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

An allocation refusal must remain a returned query error. On `4.2-dev`,
an invalid append checkpoint currently panics during cleanup and can
replace the original allocation error.

Make `Vector.RollbackAppend` return a terminal allocation-invariant
error instead of panicking. Validate checkpoint bounds, negative
attempted-row counts and row-range overflow before changing vector
length, area, bitmaps or sorted state. Retain owned capacity for
eventual `Free`.

Propagate rollback failures through both retained join-batch append
paths. Continue restoring the other affected columns after one rollback
fails, and do not publish a restored batch row count unless every column
was restored. Preserve the original error object when rollback succeeds;
retain both causes when it fails so an invariant violation is not
classified as retryable memory pressure.

Adapt the fix to the release branch's checkpoint layout and callers
without importing main-only metadata or Parquet changes. Keep allocator
ceilings, join row addressing and memory budgets unchanged.

## Validation

- CPU tests on Go 1.26.4: complete `pkg/container/vector` and
`pkg/sql/colexec` suites passed.
- Small regressions cover invalid checkpoint bounds, row-range overflow,
allocator refusal, prefix preservation and balanced cleanup; append
checkpoint and failed-append reuse controls passed.
- Formatting, diff checks and repository convention checks passed. No
big-data or GPU verification was run.
- Full `make static-check` passed with the release-pinned tools on Go
1.26.4; golangci-lint reported 0 issues.

## CI verification

The revoked-role integration test now fences the revocation committed on
CN0 before checking denial on CN1, using the existing fixture
commit-publication helper. All text/binary prepared and DDL denial
assertions remain intact; no sleep, retry or timeout increase.

- Exact failing test passes with Go 1.26.4:
`TestIssue29399AuthorizationScopeAndRevokedRole` (15.151s).
- Complete pre-push gate passes with the release-pinned tools: zero
issues.
- Latest authoritative `4.2-dev` merged; no main-branch merge.

This branch was previously deployed

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

Labels

kind/api-change 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.

3 participants