← Back to Pull requests

[fix](ivm) Use Stream versions for Cloud IVM scans and pruning #70880

Closed
unknown closed this pull request without merging on Nov 27, 2026 02:39 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 09:34 UTC
Author

Background

Cloud IVM uses the Stream's consumption offset, end TSO, and partition visible version from Meta Service. Incremental joins combine changes with base table snapshots. A COMPLETE refresh rebuilds rows and resets the Stream baseline. A partial rebuild can read a dimension at its previous consumption offset and hold the task's recorded snapshots until the incremental refresh catches up.

What problem does this PR solve?

Issue Number: None
Related PR: #62606 (incremental join rewrite), #68390 (partition rebuild bookkeeping), #69850 (stream partition scan state)
PR Type: Bugfix

Problem Summary:

Cloud IVM reads could skip rows or report a partition as current while the FE cache lagged Meta Service. With FE at partition version 1 and Meta Service at version 2, a COMPLETE refresh used to advance the Stream but miss the inserted row (7, 100). A partial rebuild in the same version mismatch could report success and leave an empty MV with pending Stream data. The fix makes scan planning and freshness checks use the Stream's read state so the COMPLETE refresh sees the row and the partial rebuild keeps its metadata pending until the delta catches up.

Details

  • Change map: 449 changed production lines cover shared Stream boundaries, fixed post scans, empty-partition pruning, and partial-rebuild freshness. 722 test lines and 90 generated result lines exercise those paths.

  • Frequency: Intermittent when the FE's partition version cache lags Meta Service or a load publishes between version lookups.

  • Root cause: Incremental branch selection and post scans used independently sourced versions. The fixed scans produced by COMPLETE could still prune against the source table cache. The historical Stream read used that cache to decide whether a partition it skipped was empty.

  • Why existing tests missed it: The closest join suites did not hold the FE cache behind the Stream cutoff. The original pruning test expected delegation to the base table. Partial rebuild tests covered a dimension with a historical offset but did not simulate its first write appearing only in Meta Service.

  • Fix: Acquire one batch of Stream read states before incremental planning locks the tables, and reuse it for branch selection, scans, and consumption. Pass each scan its Stream and captured read state through the same snapshot API. The post scan adds fixed partition versions to the existing scan parameters while preserving any requested changelog mode. Preload only live source partitions and preserve fresh version lookup for other scans in statements containing a pinned changelog scan.

  • Other paths and branches: Both IVM key models use these snapshot operations. This PR targets master. The Cloud-specific SQL regressions use the nonConcurrent group, which the public cloud_p0 runner excludes.

  • Behavior change: Cloud IVM Stream delta and base-table scans use the same captured read boundary. A partial rebuild is recorded as current after it covers the required changes.
  • Testing

    The FE build passed with zero Checkstyle violations. Cloud baseline and candidate runs used the same partial-rebuild scenario. The baseline reported success, left the MV empty, and did not catch up the Stream. The candidate reported the injected delta failure, then produced both expected join rows and brought the Stream to zero lag on retry. The next refresh rebuilt zero partitions. The final candidate passed 108 FE unit tests and eight targeted Cloud suites. The earlier snapshot-context commit passed 591 FE tests and all 134 Cloud IVM suites. The COMPLETE comparison recovered (7, 100) and advanced the Stream when the FE cache still showed version 1.

    Release note

    Cloud IVM now uses the selected Stream version consistently for join snapshots and empty-partition pruning. A partial rebuild that still needs its incremental changes remains pending until those changes are applied.

    Check List (For Author)

  • Behavior changed: Yes (see Details)

  • Does this need documentation: No

  • Pre-submission status: Ready
  • Diff: 509 lines (+381 / -128) across 6 files Reviewer: morrySnow Review duration: 5344m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 509 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.373
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #70880"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 47.6% (MEDIUM) · Higher = larger blast radius
    47.6%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 18.8% · Safe to merge
    18.8%
    Repository