← Back to Pull requests

[fix](ivm) Check layout signatures during partition refresh #70839

Closed
unknown closed this pull request without merging on Nov 23, 2026 04:29 UTC
View on GitHub
unknown unknown commented on Nov 21, 2026 15:15 UTC
Author

Background

A merge-on-write incremental materialized view stores a signature of its normalized write plan. The signature protects row identity and aggregate state layout across refreshes. A partition refresh rebuilds a subset of the view from its base tables.

What problem does this PR solve?

Issue Number: None
Related PR: #70785 (establishes the signature on the first successful write)
PR Type: Bugfix

Problem Summary:

A partition refresh could write a different layout into part of a view while other partitions retained the stored layout. Compare the signature before each partition write. A strict refresh reports a mismatch and a request that allows fallback runs a whole-view COMPLETE.

REFRESH MATERIALIZED VIEW ivm_part_sig_mv PARTITIONS;

| With a changed signature | Task result |
| --- | --- |
| Before | SUCCESS with a partial refresh |
| After | FAILED with IVM layout signature mismatch |

Details

  • Change map: The FE changes add 90 and remove 45 lines. The FE and regression tests add 141 and remove 31 lines, plus 28 generated result lines.

  • Frequency: Always when a MOW IVM partition rebuild has work to do and generates a signature different from the stored one.

  • Root cause: MTMVTask used the full refresh rewrite mode for partition rebuilds. IvmNormalizeUniqKeysMTMV compared signatures for incremental writes, and the full mode only generated a candidate signature.

  • Why existing tests missed it: The normalizer unit tests and test_ivm_plan_signature_fallback checked signature changes on the incremental write path. The partition rebuild regressions kept the layout fixed.

  • Fix: Select PARTITIONS or COMPLETE by the actual refresh scope for both IVM table models. Keep the shared stream rewrite and do the stored-signature check in the MOW normalizer, including for dirty partitions rebuilt before INCREMENTAL. Expose mode predicates through the context. When the stored signature is unset, the first successful write establishes it.

  • Other paths and branches: COMPLETE still checks its own batch signatures for consistency and can replace the baseline on success. Append-only DUP and ordinary materialized views keep their existing refresh paths. This change follows the signature lifecycle in #70785 on master.

  • Behavior change: Strict partition rebuilds fail before writing a mismatching batch. Fallback-enabled requests rebuild the whole view and publish its new signature on success.
  • Testing

  • On the previous base, test_ivm_partition_signature_fallback reproduced a successful strict partition refresh with signature drift before the fix. The test passed with the fix and verified strict failures, unchanged rows, COMPLETE fallback, and a subsequent matching partition refresh.

  • On the rebased branch, six local IVM regressions passed. The signature mismatch and DUP partition rebuild regressions passed again after the mode split and rewrite setup were finalized. A separate DUP COMPLETE refresh succeeded.

  • The standard FE runner passed 120 focused tests on the revision before the final refactors, including signature checks, the incremental rewrite, the rewrite context, and MV creation. All six rewrite-context tests passed on the final revision.
  • Release note

    None.

    Check List (For Author)

  • Behavior changed: Yes (see Details)

  • Does this need documentation: No

  • Pre-submission status: Ready
  • Diff: 428 lines (+321 / -107) across 5 files Reviewer: morrySnow Review duration: 2233m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 428 lines diff across 5 files
    0.45
    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.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #70839"
    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: 45.1% (MEDIUM) · Higher = larger blast radius
    45.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: 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: 17.8% · Safe to merge
    17.8%
    Repository