Skip to content

fix: preserve projected files across rebased writes - #9219

Merged
Xuanwo merged 6 commits into
mainfrom
gatekeeper/fix-9217-1
Sep 30, 2026
Merged

Xuanwo merged 6 commits into
mainfrom
gatekeeper/fix-9217-1

Conversation

@lance-gatefixer

@lance-gatefixer lance-gatefixer Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • apply a rebased Delete by updating only the deletion file on the current fragment, including when Project may alter nullability
  • prune fully projected-out files from updated and newly written fragments in every Update mode
  • preserve files that still contain any live field and keep the field-id watermark correct

Root cause

Delete and Update manifest application reused fragment post-images staged against the transaction read version. When a concurrent Project pruned files whose fields were all removed, those stale post-images could restore the files during rebase. RewriteColumns could also restore a newly written file for a column the Project had removed.

Delete now carries only its deletion-file delta onto the current fragment. The same rule covers a Project with preserves_nullability set to false; both Update rewrite modes are rejected earlier by the nullability conflict pre-check. Update filters both updated and new fragment files against the live projected schema while retaining mixed files that still contain a live field.

Validation

  • cargo fmt --all
  • cargo test -p lance-table
  • cargo clippy --all --tests --benches -- -D warnings

Fixes #9217

@github-actions github-actions Bot added the bug Something isn't working label Sep 14, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 14, 2026
@lance-gatefixer lance-gatefixer Bot changed the title fix: preserve projected files when rebasing deletes fix: preserve projected files across rebased writes Sep 14, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 14, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 14, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 16, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 16, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 17, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

With #9218 now in the base, this revision cleanly supplies the remaining Update half: it applies Project’s live-field rule to both staged updated fragments and new fragments, preserving mixed files while preventing fully projected-out files from returning. The strengthened Delete regression confirms the two fixes compose.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 17, 2026
@Xuanwo
Xuanwo merged commit 8102a98 into main Sep 30, 2026
38 checks passed
@Xuanwo
Xuanwo deleted the gatekeeper/fix-9217-1 branch September 30, 2026 07:45
Xuanwo pushed a commit that referenced this pull request Sep 30, 2026
## Problem and context

An update can fail when a fragment stores its row lineage in data-file
columns:

```text
cannot commit fragment ...: it marks row lineage field -3 as spilled
but none of its data files carries it
```

Row lineage records each row's stable ID, creation version, and
last-update version. To keep large per-row sequences out of the
manifest, Lance's opt-in spilled-lineage feature can store them as
hidden columns in a fragment's data files. Their reserved field IDs
(`-3`, `-4`, and `-5`) are absent from the user schema. A fragment's
metadata marks which sequences use this storage, and its file list must
retain the files carrying those columns.

The regression comes from the interaction between two changes:

- #9339 added spilling for updates and preserved lineage files across
schema changes in the Project and DataReplacement paths.
- Later, #9219 added file pruning to the Update manifest path. This
pruning is necessary when an update was prepared before a concurrent
Project removed a user column: committing the older update must not
restore files containing only removed columns. It filters both updated
fragments and newly written fragments against the current user schema.

The new Update pruning checked only user-schema field IDs. Consequently,
it also discarded files containing only hidden lineage columns. This
check runs during Update manifest construction even without a concurrent
schema change, so an ordinary update can trigger the failure.

For example, a fragment can have these files:

```text
fragment
|-- data.lance       [live user field 0]
|-- old-column.lance [removed user field 1]
`-- lineage.lance    [hidden row ID field -3]
```

Pruning should remove `old-column.lance` and retain the other two.
Before this fix it also removed `lineage.lance` from the fragment's file
list, while the metadata still said row IDs were stored in a column.
Commit-time validation then rejected the inconsistent manifest. The
observed failure is a rejected commit; this pruning does not physically
delete the file.

This reproduced in five existing spill tests and caused the Rust CI
failures on Linux x86_64, Linux ARM, Windows, and macOS observed on
#9034. The failure is in shared Update manifest construction and does
not depend on that PR's ignored-index option.

## Fix

In both Update pruning locations, retain a file when it contains either
a live user field or a spilled lineage field required by that fragment's
metadata. This follows the existing Project rule, preserves all three
lineage kinds, and continues to remove files containing only
projected-out user fields. Carrier validation remains in place. No
public API or file format changes are needed.

Extend the existing Update manifest regression across the unspecified
update mode, RewriteRows, and RewriteColumns, each with and without
spilled lineage (six cases). The v2 fixtures use separate files for row
IDs, creation versions, and last-update versions, and assert the exact
retained file lists for both updated and new fragments.

The second changed file only completes the restore/config conflict
test's `TransactionRebase` initializer. Its six missing fields otherwise
prevent Rust test targets from compiling on the base revision; this is a
separate test-build fix.

## Validation

- Before the fix: the spill suite had 31 passes and 5 failures with the
missing-carrier error.
- `cargo test -p lance-table --locked`: 580 unit tests and 3 doc tests
passed.
- `cargo test -p lance --lib --locked`: 4488 passed, 0 failed, 3
existing ignored tests; all five previously failing spill cases passed.
- The six Update manifest regression cases passed again after the
test-only clippy cleanup.
- `cargo fmt --all` and `cargo clippy --all --tests --benches -- -D
warnings` passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: a legacy Delete reinstates a data file a concurrent Project pruned

1 participant