Repository navigation
fix: preserve overlays across rebased deletes - #9218
Conversation
There was a problem hiding this comment.
❌ Gate recommendation: request changes.
Preserving the overlay file is necessary, but a rebased delete must also preserve the current fragment state that gives the overlay its semantics. Apply the staged deletion to the current fragment instead of replacing it with a stale post-image so overlay lineage and other concurrently committed fragment state survive.
| // The post-image was built at the transaction's read | ||
| // version, so carry forward overlays that may have been | ||
| // committed while the delete was being rebased. | ||
| updated.overlays = f.overlays.clone(); |
There was a problem hiding this comment.
This preserves the overlay file but leaves last_updated_at_version_meta from the stale delete post-image. On a stable-row-id dataset, DataOverlay stamps every covered row to its commit version; after this delete rebases, the overlay value remains while its row version rewinds. DatasetDelta::get_updated_rows filters on that version, so downstream change-data consumers silently miss the overlay update.
Start from the current fragment and apply only the staged deletion file (or otherwise preserve current lineage together with the overlay). That also avoids the same stale-post-image mechanism tracked in #9217.
Reproducer
Added temporarily beside the existing manifest tests and ran cargo test -p lance-table test_delete_build_manifest_preserves_concurrent_overlay_lineage:
#[test]
fn test_delete_build_manifest_preserves_concurrent_overlay_lineage() {
let row_ids = RowIdSequence::from([10u64, 11].as_slice());
let version_meta = RowDatasetVersionMeta::from_sequence(
&RowDatasetVersionSequence::from_uniform_row_count(2, 1),
)
.unwrap();
let fragment = Fragment {
id: 1,
files: vec![],
overlays: vec![],
deletion_file: None,
row_id_meta: Some(RowIdMeta::Inline(write_row_ids(&row_ids).into())),
physical_rows: Some(2),
last_updated_at_version_meta: Some(version_meta.clone()),
created_at_version_meta: Some(version_meta),
};
let base = make_stable_row_id_manifest(vec![fragment.clone()]);
let overlay = Transaction::new(
base.version,
Operation::DataOverlay {
groups: vec![DataOverlayGroup {
fragment_id: 1,
overlays: vec![overlay_with_field(0, 0)],
}],
},
None,
);
let (current, _) = overlay
.build_manifest(Some(&base), vec![], "overlay", &default_build_config())
.unwrap();
assert_eq!(last_updated_at_versions(¤t, 1), vec![5, 1]);
let delete = Transaction::new(
base.version,
Operation::Delete {
updated_fragments: vec![fragment],
deleted_fragment_ids: vec![],
predicate: "id = 11".to_string(),
},
None,
);
let (rebased, _) = delete
.build_manifest(Some(¤t), vec![], "delete", &default_build_config())
.unwrap();
assert_eq!(rebased.fragments[0].overlays.len(), 1);
assert_eq!(last_updated_at_versions(&rebased, 1), vec![5, 1]);
}The final assertion failed with left: [1, 1], right: [5, 1].
There was a problem hiding this comment.
Addressed in 6db5faa: rebased deletes now retain the current fragment and apply only the staged deletion file, preserving overlay lineage and all other concurrent fragment state. The regression now covers the deletion file, overlay, and row-version metadata together.
There was a problem hiding this comment.
Fixed in 6db5faac4: the delete now applies only its staged deletion file to the current fragment, preserving both concurrent overlays and their row-version lineage. The regression covers the deletion file, overlay, and last_updated_at_version_meta together.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The prior row-lineage issue is fixed. Applying only the staged deletion file to the current fragment preserves concurrent overlays, lineage, and other fragment state, and the regression covers those invariants together.
Summary
Root cause
The Delete manifest arm replaced an updated fragment wholesale with a post-image built at the transaction read version. Because conflict resolution permits concurrent fragment-preserving operations such as DataOverlay, that replacement discarded state present only in the newer current manifest.
Validation
cargo test -p lance-tablecargo fmt --allcargo clippy --all --tests --benches -- -D warningsFixes #9216