← Back to Pull requests

[fix](ivm) Prevent NULL-row loss during outer join refresh #70630

Closed
unknown closed this pull request without merging on Nov 18, 2026 08:12 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 09:34 UTC
Author

Background

Incremental materialized views maintain outer joins by writing joined-row changes and repairs for rows whose nullable side is filled with NULL. Unique-key views apply these writes through merge-on-write keys and sequence numbers.

What problem does this PR solve?

Issue Number: None
Related PR: #62606 (introduced the bug)
PR Type: Bugfix

Problem Summary:

Incremental refresh can lose a padded NULL row when the nullable-side join subtree emits cancelling positive and negative events. Order NULL-row repairs by their operation sign so reinsertion wins when both repairs target the same row.

For a view over l LEFT JOIN (a JOIN b), updating the outer join key in a and deleting its matching b row in the same refresh window produced:

| Result | Rows |
|---|---|
| Before the fix, one observed incremental refresh | (1,10,NULL) |
| With the fix, incremental and complete refresh | (1,10,NULL), (2,20,NULL) |

Details

  • Frequency: Intermittent when changes to both inputs of a nullable-side join produce cancelling rows within one refresh window.

  • Root cause: paddingSequence() ignored the repair sign. Both the NULL-row deletion and reinsertion used the same sequence, so merge-on-write could retain the deletion according to arrival order.

  • Why existing tests missed it: IvmJoinDeltaHandlerTest checked the repair sign and sequence column name without checking their ordering. test_ivm_refresh_dry_run masks the sequence value, while final-row checks can pass when reinsertion happens to arrive last.

  • Fix: Reuse the existing signed sequence encoder in both the general repair and equality-event paths. Preserve the refresh prefix and delta index, and distinguish repairs using the existing operation bit without adding scans or joins.

  • Other paths and branches: LEFT, RIGHT and FULL joins share these repair producers. BIGINT and LARGEINT encodings are covered; the aggregate final-sequence path and append-only detail model are unchanged. The handler introduced by #62606 is absent from branch-3.1, branch-4.0, branch-4.1 and branch-4.2.

  • Behavior change: DRY RUN now exposes an even sequence for negative NULL-row repairs and a larger odd sequence for positive repairs; its result schema is unchanged.
  • Testing

  • Three targeted unit tests fail on the unpatched code at the repair-sequence assertions.

  • The IVM regression directory passed locally: 117 suites, zero failures and zero skips, including the new test_ivm_outer_join_null_repair_sequence case for equality events, residual predicates, RIGHT JOIN and FULL JOIN.

  • All 526 tests across 33 IVM and create/show/drop materialized-view test classes passed locally. The final combined standard-runner check passed 141 tests.
  • Release note

    None

    Check List (For Author)

  • Behavior changed: Yes (see Details)

  • Does this need documentation: No

  • Pre-submission status: Ready
  • Diff: 365 lines (+273 / -92) across 4 files Reviewer: morrySnow Review duration: 2797m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 365 lines diff across 4 files
    0.43
    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.353
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #70630"
    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: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    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: 16.9% · Safe to merge
    16.9%
    Repository