← Back to Pull requests

[File-level concurrency] Conflict-time data skipping (min/max stats tier) #7358

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Aug 04, 2026 20:30 UTC
Author

Addresses #4470 (improved concurrency model for liquid / unpartitioned tables) at the file level — avoid conflicts when concurrent transactions touch disjoint files, decided by column statistics without reading row values. Part of the concurrency umbrella (#7360) — Case 1. Full design and rationale: #7356.

Summary

Reader-side conflict-time data skipping. Conflict detection currently filters candidate files by partition only. On an unpartitioned table — which includes every liquid-clustered table — getFirstFileMatchingPartitionPredicates returns files.headOption, so the append check conflicts on any concurrently-added file, even when the two operations touch entirely disjoint data ranges. This is the dominant source of false conflicts for liquid clustering, where incremental clustering and DML usually touch different clustering-key regions.

This teaches conflict detection to apply the reader's column-statistics data skipping: an added file whose stats prove it cannot match the current transaction's data predicates is excluded from the conflict check.

What it does

  • ConflictChecker.getFirstFileMatchingPartitionPredicates now uses the data predicates of the current transaction's reads (DeltaTableReadPredicate.dataPredicates, previously ignored). On a partitioned table, each read's data predicates are combined only with that read's own partition predicate, so a concurrently-added file conflicts iff it could match P_i AND D_i for some read i. On an unpartitioned table, the reads' data predicates are OR-combined. Skipping isn't applied for a whole-table read, or when the transaction has no read predicates.

  • ConflictDataSkippingReader, mixed into DataSkippingReaderBase, builds the skipping condition with the reader's DataFiltersBuilder and verifyStatsForFilter. It shares stats parsing (parseStats) and filter eligibility (DataSkippingReader.isIneligibleForDataSkipping) with the scan path.

  • Added files are checked in batches (spark.databricks.delta.conflictDetection.dataSkipping.batchSize, internal, default 1000), so the check stops at the first batch with a matching file.

  • If building or evaluating the skipping condition fails, the check records delta.conflictDetection.dataSkipping.fallback and treats the added files as conflicts, as with the feature off. A commit that used skipping records delta.conflictDetection.dataSkipping.applied once, with the committed version.

  • Gated by spark.databricks.delta.conflictDetection.dataSkipping.enabled (internal, default off). No protocol / reader / action changes.
  • Which operations benefit (not just append)

    The improved check is the added-files (append) check, which fires whenever the winner adds data files — so it is not only INSERT. UPDATE/MERGE add new row-image files, and because those are non-blind changed-data files they are checked under the default WriteSerializable (a blind INSERT is only checked under Serializable). So the headline beneficiaries are concurrent UPDATE / DELETE / MERGE on disjoint clustering ranges (different files), under the default isolation.

    This complements the same-file DV merge (#7357), splitting the space by which check fires:

    | Concurrent DML shape | Check that fires | Handled by |
    |---|---|---|
    | different files (disjoint ranges) | append check | this PR (Case 1, #7356) |
    | same file, disjoint rows | delete/delete, delete/read | #7357 (Case 2, DV merge) |
    | same file, same rows | delete/ | neither (genuine conflict) |

    Roles: the loser supplies the read predicate (WHERE / MERGE ON); the winner supplies the added files whose stats are pruned. (A DV-DELETE winner re-adds the same file, so that's #7357's same-file case, not this PR's.)

    One-way safety

    Data skipping here is sound in one direction only — a file is skipped only when its stats prove no overlap; a wrongly-skipped file would be a missed conflict. Guaranteed by reusing the reader's machinery:

  • expr || !verifyStatsForFilter(referencedStats) keeps any file whose referenced stats are missing/NULL.

  • Deletion-vector (tightBounds=false) stats are safe: updateStatsToWideBounds keeps min/max as valid outer bounds (a superset of live values), so wide bounds only cause fewer skips, never an unsafe one — the same property the reader uses to skip DV'd files. The effect on DV-heavy files is reduced benefit (conservative keep), not incorrectness.

  • Subquery / non-deterministic / metadata-column filters are dropped up front, with the same check as filesForScan. Dropping a conjunct only widens the condition.

  • Data predicates from independent reads are OR-combined, never AND-combined; whole-table reads disable skipping entirely; an empty read-predicate set on a non-blind txn keeps all files.
  • Correct across clusters/JVMs by construction — conflict detection is log-based: the loser reads the winner's committed stats from _delta_log and evaluates skipping against its own local predicates (no shared state; deterministic; other-engine/no-stats writers are kept).

    Supersedes #7357's op-type append-suppression

    The #7359 POC (issue #7357) shortcut the concurrent-UPDATE case with a blanket append-suppression for rewrite-only DML winners — skipping all* their new image files in the append check, keyed only on the winner's op type. That is unsound: an UPDATE can flip a row into the loser's predicate (winner SET x=15, loser DELETE WHERE x>10, row was x=5), a genuine write-skew the suppression hides. Those image files are ordinary non-blind changed-data files and are correctly arbitrated by this PR's stats-based skip — abort on stats overlap (real flip), reconcile only on proven no-overlap, keep on missing stats. #7357 drops the suppression and depends on this PR; they stack (this data skipping under the DV merge).

    Testing

    ConflictDataSkippingSuite (new, 26 tests) runs concurrent transactions in a fixed order:

  • disjoint vs overlapping data ranges, feature disabled, missing stats, null stats, and whole-table reads;

  • partitioned tables, including a read's data predicates paired only with its own partition predicate;

  • AND-combining predicates within one read and OR-combining independent reads;

  • concurrent UPDATE and MERGE, including an UPDATE that moves a row into the read range (conflicts) or out of it (doesn't);

  • deletion vectors: DELETEs in disjoint files, DELETEs of different rows in the same file, and a DV file whose stats still cover its deleted rows;

  • column mapping (name mode);

  • non-deterministic and unusable predicates, alone and ANDed with a usable one;

  • spark.databricks.delta.stats.skipping disabled;

  • a skipping evaluation failure falling back to conflicts, on unpartitioned and partitioned tables;

  • batches: a conflict found in a later batch, and a batch whose DataFrame fails to build being retried by the next probe;

  • the applied event: not recorded when the winner adds no files, and recorded once per commit across several winning commits.
  • With the flag off, conflict detection is unchanged: the unpartitioned check returns the first added file, and the partitioned check runs the same partition probe as before.

    🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: sezruby Review duration: 159417m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.59 · 650 lines diff across 8 files
    0.59
    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%
    44%
    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.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #7358"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.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: 59% (MEDIUM) · Higher = larger blast radius
    59%
    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: 44.7% · Lower = rushed or shallow review
    44.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: 32.6% · Safe to merge
    32.6%
    Repository