← Back to Pull requests

[core] Reclaim consumed merge batches with pending output #1390

Open
unknown opened this pull request with 254 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 12, 2026 10:06 UTC
Author

Purpose

Linked issue: close #1386

A partially filled output batch keeps output_indices nonempty. If many later keys are omitted because their winning rows are retracts, consumed source batches remain in batch_buffer until the output fills or input ends. Reclaim unrelated batches while keeping both cursor and pending-output references valid.

Brief change log

  • Mark pending output batches as live during buffer compaction and remap their indices alongside cursor indices.

  • Compact when retained batches exceed twice the upper bound of cursor/pending-row references, amortizing cleanup without changing output batch sizing.

  • Add a lazy two-stream regression with three surviving keys and many deleted keys. Observe source-array ownership through Weak references and verify output keys, values, order, batch count, and eventual release.
  • Tests

  • The new regression fails before the fix with 128 observed retained source arrays; after the fix it passes the bound of at most 16.

  • cargo +1.95.0 test --locked -p paimon --lib table::sort_merge::tests: 42 passed.

  • cargo +1.95.0 test --locked -p paimon --lib: 4,860 passed, 6 ignored.

  • Targeted Clippy passed with -D warnings -A clippy::nonminimal_bool. Strict Clippy's six existing nonminimal-bool errors were reproduced on unmodified main; no source lint suppressions were added.

  • cargo +1.95.0 fmt --all -- --check and git diff --check: passed.
  • Local Cargo builds used debug info disabled and incremental compilation disabled. The regression measures retained source-array ownership, not RSS. This change does not establish a byte budget for all merge state or address a single key with arbitrarily many versions.

    API and Format

    No public API or storage-format changes. Pending output retains its original rows and order; output batch sizing is unchanged.

    Documentation

    Update the buffer ownership and compaction comments beside the implementation.

    AI assistance: Codex helped develop the implementation, regression, and this description.

    Diff: 254 lines (+190 / -64) across 3 files Reviewer: JeonDaehong Review duration: 4256m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.44) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 254 lines diff across 3 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.332
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #1390"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.1% (MEDIUM) · Higher = larger blast radius
    44.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.5% · Safe to merge
    23.5%