Skip to content

fix: preserve sinker batch ownership on write failures - #31647

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/sinker-write-ownership-31283
Oct 29, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/sinker-write-ownership-31283

Conversation

@MatrixAdventurer

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Fixes #31283

What this PR does / why we need it:

A failed Sinker.Write can return the same staged batch to the freelist twice: pushStaged takes ownership before spilling, but Write still returns its local reference on error. Clear that reference at all three ownership-transfer sites so cleanup returns the batch exactly once.

WriteOwned can also transfer a batch before a spill fails. The MultiUpdate caller now drops its reference whenever owned is true, including on error, and retains responsibility when the transfer was rejected.

The regression tests reproduce all three double-return paths and inject an object-store write failure through the real MultiUpdate writer. They also cover rejection before ownership transfer. Both original failure regressions fail on the base revision and pass with the fix.

Validation

  • go test -p 4 -count=1 ./pkg/objectio/ioutil ./pkg/sql/colexec/multi_update (passed).
  • Targeted MultiUpdate ownership tests, including pre-transfer rejection (passed).
  • git diff --check (passed).

@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 →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 29, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 29, 2026
@XuPeng-SH

XuPeng-SH commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 45ef9bdc4f59530a7db4dc0c157bce258da7fed7

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: 45ef9bdc4f59530a7db4dc0c157bce258da7fed7

Assessment: approve

The fix preserves single batch ownership across write failures and correctly distinguishes transferred from rejected inputs. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Both affected packages passed normal and race tests, including every new regression; receipts and logs are reconciled in validation-summary.json.

  • Baseline production-file controls reproduced both ownership defects; the pre-transfer rejection control passed.

  • Build, vet, gofmt and diff whitespace checks passed.

  • Artifact audit confirmed the frozen head, unchanged source, native provenance hashes and complete discussion assessment.

Limitations:

  • Validation covered CPU/Linux package tests; SQL BVT and distributed-cluster tests were not run.

@mergify mergify Bot added the queued label Oct 29, 2026
@mergify

mergify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

49 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 29 Oct, 04:29 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 05:17 · 25382e6

Reason

Pull request #31647 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Merge conditions: 2 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
❌ any of: check-neutral = CI Required, check-skipped = CI Required, check-success = CI Required GitHub branch protection

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit 4343b4f into matrixorigin:main Oct 29, 2026
26 of 27 checks passed
@mergify mergify Bot added dequeued and removed queued labels Oct 29, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued 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]: failed Sinker.Write returns its buffer to the freelist twice; failed WriteOwned traps the caller's batch

3 participants