Repository navigation
test: characterize legacy conflict resolution end to end - #9220
Conversation
The existing matrix in `conflict_resolver::tests::test_conflicts` builds `TransactionRebase` as a struct literal over bare `Fragment::new(0)` values, calls `check_txn`, and asserts the verdict. It never calls `finish`, so no manifest is ever built. That pins the verdict table and can observe nothing downstream of it: the second phase, the resulting manifest, or anything depending on real fragment contents. Add a suite on the other axis. Each case stages a real transaction through a production write path, lets a second transaction commit underneath it, then commits it for real -- so the assertion is about the manifest and the rows a reader gets back, not an intermediate verdict. - `scenarios.rs` stages twelve operations, using the uncommitted builders (`InsertBuilder`, `DeleteBuilder`, `MergeInsertBuilder`, `CreateIndexBuilder`, `FileFragment::write_overlay`) wherever one exists. - `invariants.rs` holds six properties checked after every landing, stated over observable dataset state rather than resolver internals. - `cases.rs` holds all 144 ordered pairs. Ordered, not unordered: the legacy matrix is asymmetric in many places, and a harness that loops `[(a, b), (b, a)]` against one expectation cannot express that. Expectations are filled in from observed behaviour via the `discover` tool, not derived from reading match arms. Four cells are excluded and written up as `#[ignore]`d tests against tracking issues, because what the code does with them today is wrong: - lance-format#9216 -- a `Delete` drops a concurrently committed `DataOverlay`. The overlaid cell reverts to its base value, visible from a plain scan. - lance-format#9217 -- `Delete` and both `Update` modes reinstate a data file a concurrent `Project` pruned, leaving a file the schema cannot reach. The whole suite runs in ~0.3s. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
DecisionCharacterization suite for legacy conflict resolution, landing on StatusSettled 2026-09-14. Implemented in this PR. Options and criteriaThe acceptance criterion is that this suite must pass unchanged when the TV2 stack merges. If it doesn't, the stack changed legacy behaviour, and that is the signal we want. So assertions are over observable state — the manifest a reader loads and the rows a scan returns — never over
Rejected, with the reason and when it was tried
Open questions
|
| /// dropped, because a projection only prunes a file when *all* of its fields go | ||
| /// away. Asserting the stronger "every field id appears in the schema" would | ||
| /// fire on an ordinary single-fragment projection with no conflict at all. | ||
| fn no_orphaned_data_file(after: &Dataset, context: &str) { |
There was a problem hiding this comment.
suggestion: some of these tests looks like they just duplicate Dataset::validate(). Perhaps we should just re-use that for parts of the invariant validations.
The suite asserted that a rebased dataset was structurally coherent, but nothing about the rows it held: the only row-count check compared a scan against the manifest's own accounting, which is self-referential. A rebase producing the right number of valid rows with the wrong values in them passed. Add `oracle`, which re-runs each pair serially from a fresh fixture and compares the full content. That is a serializability check, so the pairs where snapshot isolation legitimately diverges are listed with the reason. Its first run found one: a data replacement deliberately keeps an overlay committed after its own snapshot, because that overlay is the newer value, while serial execution lets the replacement win the cell. Name the level those expectations are stated under. Legacy conflict resolution is not uniformly any textbook level, so `Isolation::Legacy` records what the code does rather than claiming a contract. When levels become configurable the grid gains a dimension and each exemption becomes a per-level rule. Replace the 390-line expectation table with a parsed grid, so the whole matrix reads at a glance and regenerating it produces a reviewable diff. `discover` emits the same format. Delegate to `Dataset::validate`, dropping `no_orphaned_data_file` — which `FileFragment::validate` already covers against real IO — and gaining fragment ordering, per-file length agreement and deletion-vector cardinality. Turn stable row ids on in the fixture so its row id invariants are live; that needs `stage_rewrite` to transfer row ids the way compaction does, so widen `rechunk_stable_row_ids` rather than reimplement it. No expectation moved. Give synthetic data files unique names. The fixed name was benign only while every staging wrote identical contents. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
DecisionFour changes in
StatusCommitted and pushed. 25 tests, 4 ignored, 0.35s (was 0.30s). Options and criteriaOracle framing. Stated as a serializability check with an explicit exemption list, rather than as an ad-hoc set of per-pair expected values. Criterion: Lance intends to offer configurable isolation levels with serializable among them, so this is that conformance check built early and pointed at legacy. The exemption list is then not debt — it is the measured gap between legacy and serializable, which is an input the levels work needs. Its first run fired on exactly one cell of 140: Grid as source of truth, not a rendering. The grid is parsed at run time and Stable row ids on. Measured rather than argued: flipping the flag failed 13 of 25 tests, all from Rejected, with the reason and when it was tried
Open questions
🤖 Generated with Claude Code |
Three checks in the conflict resolver were unreachable in all 144 cells, because every scenario happened to pick the same side of them. `may_alter_nullability` is true only for a Project or Merge that does not assert `preserves_nullability`, and both stagers hard-coded it true. It gates a global pre-check that fires in either order against anything supplying values. Stage both settings. `updates_schema_or_field_metadata` is true only for an UpdateConfig carrying schema or field metadata, and no scenario emitted one. It gates the other global pre-check, against Merge. Add UpdateConfig as a scenario, updating schema metadata rather than config entries, which is what the pre-check keys on. A delete whose predicate covers a whole fragment populates `deleted_fragment_ids` instead of `updated_fragments`, which several arms key on; the existing single-row delete never did. Add it as its own scenario, and assert the shape so a fixture change cannot silently turn it back into an ordinary delete. All four change observed behaviour rather than merely reaching new code. Notably `(data_replacement, delete_whole_fragment)` is incompatible where `(data_replacement, delete)` lands — a verdict change, not just a different arm — and the nullability column turns eight cells retryable that were landing. It also widens a known bug: `(delete, project_alter_nullability)` reinstates a pruned data file through the same apply arm as `(delete, project)`, so lance-format#9217 costs one more cell than recorded. The matrix is now 16x16. 33 tests, 0.42s. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Every scenario in the matrix staged against fragment 0, so every fragment-scoped pair in it overlapped. That made the suite a good detector of under-rejection and a poor one for the opposite mistake: a conflict resolver that rejected everything outright would have scored nearly as well as one that reasons about footprints, because the matrix never asked a question whose answer depended on the footprint. Add `Footprint`, which says which fragment `theirs` touches, and a second grid over the eight fragment-scoped operations recording both answers per pair. Thirty of the sixty-four cells differ between the two, so legacy does resolve most of these by footprint; three reject on opcode alone, which is now recorded rather than unasked. `(data_replacement, delete_whole_fragment)` is incompatible when the two overlap and lands when they do not. Scope `stage_create_index` to a single fragment. A whole-dataset index has no footprint to compare, and `fragment_bitmap` is what the rewrite arms of `check_create_index_txn` key on. No cell in the existing matrix moved. Fix the oracle to stage `theirs` at the footprint under test. It re-staged at the default, so the serial comparison ran a different pair of operations than the rebase it was checking. Field-level overlap is deliberately not covered: it only means anything for the three field-scoped operations, and the fixture cannot express it cleanly while `a` and `b` share a data file. Stated in the module docs rather than approximated. 42 tests, 0.66s. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
DecisionTwo more commits: Branch coverage. Three checks in the resolver were unreachable in all 144 cells because every scenario happened to pick the same side of them. All four new scenarios change observed behaviour rather than merely reaching new code:
Matrix is 16×16. Footprint. Thirty of sixty-four cells differ between the two footprints, so legacy does resolve most of these by what the operations touch. Three reject on opcode alone — StatusPushed. 42 tests, 5 ignored, 0.66s. Options and criteriaFootprint is fragment-level, not field-level. Criterion: fragment-level is cleanly defined for all eight fragment-scoped operations, while field-level only means anything for three of them, and the fixture cannot express it while A second grid rather than a third dimension on the first. Footprint is meaningless for the eight dataset-scoped operations — they produce the same transaction whichever fragment they are pointed at — so folding it into the main matrix would have doubled its runtime to assert nothing on half the cells.
Rejected, with the reason and when it was tried
Found while building
Open questions
🤖 Generated with Claude Code |
The footprint axis could previously only vary the fragment, because the fixture had exactly one column a scenario could target without disturbing another. A resolver that reasons about fragments but not fields would have scored perfectly on it. Add a fourth column `d`, in a data file of its own, and a third footprint `OtherField`: same fragment 0, column `d` instead of `c`. The three field-scoped stagers take the column as a parameter, and all of them now default to `c` — `data_overlay` moves off `b`, and `data_replacement` moves off the file `a` and `b` share, which also stops it rewriting the column the content oracle keys on. What it found, in the regenerated grid: field sensitivity is rare. Most fragment-scoped pairs read `R/R/L` — they distinguish fragments and not fields. Only three cells reason about columns at all. `project` and `merge` now drop just `c`, keeping `d`. Dropping both left `d`'s data file on a fragment whose schema no longer had `d`, which `Dataset::validate` correctly rejected — with no concurrency involved. Excludes two more cells, against a new bug the `d` column surfaced: `Operation::Project` prunes the data files of the columns it drops but never their overlays, leaving an overlay nothing will read and cleanup will not collect (lance-format#9313). Reproduces serially; recorded here because it is what makes the two data_overlay/project cells unassertable. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Field-level footprintDecisionThe footprint axis varies three footprints, not two:
StatusLanded in What it foundField sensitivity is rare. Most fragment-scoped pairs read Exactly three cells reason about columns: New bug: #9313Adding Two cells ( Rejected, with the reason and when it was tried
Open questions
|
…#9217, lance-format#9313 Expose rechunk_row_lineage (main's replacement for rechunk_stable_row_ids) for the rewrite scenario. Un-ignore the three fixed-bug tests as regression tests and regenerate both grids. The (data_overlay, project) cell stays excluded under lance-format#9724, which lance-format#9314 did not cover. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s its field (#10123) Closes #9724. A `DataOverlay` staged at version N still committed after a concurrent `Project` at N+1 dropped the field it overlays. `check_data_overlay_txn` treated every `Project` as compatible, and the overlay build arm doesn't look at the schema, so the overlay landed covering only fields that no longer exist. #9314 handles the other order, where `Project` prunes overlays that are already committed. This makes `Project` a retryable conflict for an overlay when the projected schema no longer contains one of the overlay's fields, which is the first option the issue gives. A projection that keeps all of the overlay's fields (a rename, or dropping some other column) is still compatible. Testing: `test_data_overlay_conflicts` gained two `Project` cases, one keeping the overlaid field (compatible) and one dropping it (retryable). The dropping case fails on main. `cargo test -p lance --lib io::commit::conflict_resolver` and `cargo test -p lance --lib overlay` pass, `cargo fmt --all` is clean, and `cargo clippy -p lance --lib --tests -- -D warnings` passes; I didn't run the full-workspace clippy. #9220 leaves the `(DataOverlay, Project)` cell out of its conflict matrix because of this bug; with this change it should be able to go back in. I used an AI coding assistant to help write this change and the test; I reviewed the diff and ran the checks above.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
This closes the gap between conflict verdict tests and the manifests and rows readers actually see. The previously excluded overlay/projection case is now active: #10123 is merged into the base and rejects overlays for dropped fields.
…r-9220-merge-20261101
…r-9220-merge-20261101
Xuanwo
left a comment
There was a problem hiding this comment.
Approving head bdb88ba653a28b754cfb5624d087330b14fa20f5 after the complete Rust, Python, and Java CI set passed.
The reviewed feature diff is unchanged from the Gatekeeper-approved revision; the latest main integration only brings in the repaired compatibility test. The matrix retains manifest, scan, rollback-sensitive, and serial-content assertions, including the restored #9724 regression.
Tests only. This adds an end-to-end behaviour baseline for conflict resolution between concurrent transactions, so changes to the legacy rules can be checked against the manifests and rows they produce rather than only against
check_txnverdicts.Each case stages a real transaction through a production write path, commits a second transaction underneath it, then commits the first for real. The matrix covers ordered pairs of the existing operation vocabulary and exercises both fragment and field footprints. Every landed result is checked for manifest validity, rollback-sensitive invariants, scanability, and, where the measured legacy behaviour is serializable, equality with serial execution.
The expectations describe current legacy behaviour. Known snapshot-isolation divergences remain explicit exemptions; this does not add configurable isolation levels or change the resolver. It includes regressions for #9216, #9217, #9313, and #9724, with no remaining excluded cells.
The fixture remains six rows across two fragments. Two ignored discovery tests regenerate the verdict and footprint matrices when an intentional behaviour change lands.