Skip to content

fix(disttae): budget transaction workspace batch copies - #32458

Merged
mergify[bot] merged 7 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/txn-workspace-memory
Nov 10, 2026
Merged

mergify[bot] merged 7 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/txn-workspace-memory

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

issue #32008 (partial workspace-admission hardening, not closure of the historical OOM investigation)

What this PR does / why we need it:

Transaction INSERT/DELETE copies could allocate outside execution-memory admission while staying live alongside accounted operators. Give workspace copies independent lifetime accounts on the existing CN budget, including physical-headroom checks and physical-Free refund ownership. Snapshot workspaces sharing a Process do not close each other's generations. Generic CopyBatch remains unchanged; raw WriteBatch destinations retain their own provenance.

Integrate ownership across INSERT and commit-time merge, rather than charging obsolete copies:

  • Ordinary INSERT adopts its generated rowid vector when destination provenance matches. Different destination provenance retains the necessary independent copy.
  • INSERT merge stages only surviving payload columns, omitting old rowids from both copy and append, then adopts the regenerated rowid vector. All fallible staging completes before entries, indexes or ownership are published. DELETE merge retains its original columns.
  • Partial-copy/rowid failures release temporary results; statement rollback preserves prior writes and the account, later writes still work, and terminal cleanup closes only the owned generation. Rowid allocation fixtures now close their workspace accounts.

Existing spill decisions, approximate workspace counters and unpublished-object ownership remain authoritative. No new controller, budget exception, background task, configuration, protocol or storage format.

Design: workspace ownership, reviewed design-first revision 7ebc034. Base: 745d253.

Correctness validation

  • PASS: old-production overlay rejects a fitting merge; candidate merges 30 batches of 64 distinct int64 values within 200,000 bytes. Initial charge 61,440 bytes; candidate peak 144,640 bytes. A 140,000-byte refusal retains all 30 original entries/values and the initial charge. Row count/uniqueness (1,920), zero-based rowid offsets, one resulting live batch on success, and terminal zero account/CN balances are asserted.
  • PASS: ordinary INSERT red/green at 2,500 bytes, true refusal at 1,500 bytes, raw/foreign provenance, independent close/concurrent initialization, and real RollbackLastStatement copy/rowid failures with prior writes plus subsequent successful writes.
  • PASS: complete disttae package (49.490 s), relevant focused race (3.557 s), util package, vet, incremental lint (zero issues), gofmt and diff checks. Final strengthened merge assertions also passed independently.
  • PASS: built local service executed the expanded txn_workspace_memory_bound.sql twice on one instance. Real SQL COMMIT merged thirty batches under the 200,000-byte limit with count=distinct-count=1920 and sum=1842240; all preceding fitting/refused writes and explicit rollback/continuation assertions still passed. Each run had exactly six intended capacity errors and no other errors. Test services stopped; only owned data removed; logs/checksums retained.
  • Expanded .sql/.result runner comparison and required CI checks belong to the new head and are pending, not inherited from a previous head.

Real-controller measurements and remaining acceptance

The copy benchmark now includes workspace_cn using GetExecutionResourceBudget, the real CN registry and OpenWithController (not a standalone account). One local 50,000-iteration diagnostic measured generic 967, standalone workspace account 1284, and CN-controller workspace 1850 ns/op. It is a different protocol from the earlier 1,000-iteration 1163/3725 sample, so this is not a before/after performance-improvement claim.

A bounded local real SQL/controller A/B/A compared the reviewed be4c16e production path with the merge fix. Each fresh service ran 32 transactions per stage, 30 batches x 64 unique rows per transaction. Client latency includes result validation. The mixed stage used four DML clients plus a concurrent join whose physical plan contains HashBuild; every join result was checked (257/267/283 queries). No budget test injection was used.

Stage / metric Before A1 Candidate B Before A2
Serial transactions/s 38.53 41.26 40.83
Serial p50 / p95 ms 23.77 / 33.02 23.11 / 29.38 23.57 / 31.65
Mixed transactions/s 93.28 103.13 98.68
Mixed p50 / p95 ms 39.94 / 54.17 37.32 / 48.51 35.64 / 48.08

Small samples and baseline drift prevent a statistical improvement or business-throughput acceptance claim. This comparison isolates the merge fix within the already-accounted PR, not the full PR versus pre-admission main. Allocation-count reductions do not substitute for throughput evidence.

QA required: yes. Full-PR transaction performance and fresh-capacity 16 GiB Linux/cgroup mixed DML/HashBuild pressure/soak remain NOT_RUN. Local Darwin mixed correctness/measurements do not establish hard-limit capacity safety. A new controlled Linux environment still needs admission; the original run/namespace/PVCs/receiver were not operated on. The original formal experiment remains NOT_RUN and #32008 is not declared systematically resolved.

The PR was externally marked Ready; this update preserves that state without claiming the outstanding acceptance gates passed. No release branch is changed; 4.2 needs a separate minimal-complete adaptation/dependency review rather than a mechanical cherry-pick.

CR follow-up: clean-object republication admission

Addressed XuPeng-SH's P2 in b738167f4b31: compactDeletionOnObjsLocked now stages retained clean-object metadata through copyWorkspaceBatch instead of an unaccounted Dup. Publication still occurs only after all fallible staging succeeds.

The existing mixed clean/dirty-object compaction fixture now saturates the CN controller before republication, checks a capacity error before any new object persists, and preserves the original batch, deletion marks, entries and charge. It also checks that a later dirty-rewrite refusal refunds all staged clean copies, then restores capacity, retries, verifies every replacement/republication account and terminal zero balances. The prior production overlay fails the new refusal oracle by persisting an extra replacement first.

PASS: final focused regression/race (3.836 s, test debug symbols stripped with native link flags retained), full disttae package (58.604 s), vet, incremental lint, formatting/diff checks. The expanded cn_spill_byte_bound SQL passed twice on a newly built non-SIMD, stripped local diagnostic service, including a same-transaction mixed-object insert/delete/commit and exact 63-row, unique-ID, sum and payload checks. Earlier runs against the old executable are excluded. Canonical SIMD local service builds stopped at disk-exhaustion compilation; they are not reported as passes. New-head canonical CI/BVT is pending.

All original throughput/16 GiB acceptance limitations remain. There are no inline review threads to resolve; the blocking formal review still requires the reviewer's new assessment. Ready state is preserved.

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

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

@XuPeng-SH Addressed the P2 from your review in b738167.

Clean-object republications in compactDeletionOnObjsLocked now use copyWorkspaceBatch before publication. The existing mixed-object fixture TestIssue25590CompactionRefusalRetainsDirtyObjectSources verifies memory-capacity refusal before any dirty replacement persists, unchanged original metadata/deletion marks/entries/charge, refund of staged clean copies on a later rewrite refusal, accounted republications after retry, and terminal zero balances. The old production overlay fails the new refusal oracle by persisting an extra object.

Local validation: full disttae package, focused regression/race, vet and incremental lint passed. The extended cn_spill_byte_bound.sql passed twice with exact results against a newly built non-SIMD, stripped diagnostic service; canonical SIMD local build attempts failed at compilation due to disk exhaustion and are not counted as passes. New-head CI/BVT is pending. Full-PR performance and 16 GiB Linux/cgroup pressure/soak remain unvalidated; this is still a partial main-branch admission fix, not historical OOM closure or 4.2 readiness.

No inline threads exist to resolve. Please re-review the updated head; a re-review request is being sent separately.

@XuPeng-SH

XuPeng-SH commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: b738167f4b3146dce5fe3fe7c10600ca22ab139d

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: b738167f4b3146dce5fe3fe7c10600ca22ab139d

Assessment: approve

The prior clean-object admission finding is resolved. The change coherently reuses CN accounting with independent workspace lifetimes and failure-atomic staging. No actionable findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete 22-file delta, all eight discussion entries and linked issue #32008.

  • Static audit passed: formatting, diff checks, both SQL/result pairs and independent result arithmetic. Receipt: checks/1794336990215575331-3.json; log: review-audit.log.

  • Isolation preflight passed; receipt: checks/1794336700215987307-3.json.

  • Frozen-head CI reports 13 successful checks, including build, UT, static analysis and proxy/pessimistic BVT. Skipped and neutral checks were excluded.

  • Discussion assessment and receipt reconciliation saved; source remains unchanged.

Limitations:

  • No local Go or SQL tests executed; raw author runtime logs and individual CI test logs were not supplied.

  • Full-PR throughput and 16 GiB cgroup pressure/soak remain unvalidated. This approval does not establish historical OOM closure or 4.2 backport readiness.

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

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 56ad29d at 20:13 UTC

1 h 14 min in the queue, 1 h 12 min of it CI.

So far

  • ✅ Entered the queue Tue 10 Nov, 18:58 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 20:13 · 56ad29d · 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 — 39ab9b4b Deployed Nov 10, 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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants