Skip to content

fix(table): preserve spilled row lineage during updates - #9623

Merged
Xuanwo merged 2 commits into
lance-format:mainfrom
majin1102:codex/preserve-spilled-lineage-on-update
Sep 30, 2026
Merged

Xuanwo merged 2 commits into
lance-format:mainfrom
majin1102:codex/preserve-spilled-lineage-on-update

Conversation

@majin1102

@majin1102 majin1102 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem and context

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

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:

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:

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.

Keep spilled row-lineage carriers when pruning projected files from updated
and new fragments. Extend the Update mode regression to retain separate
carriers for all three lineage fields while still dropping projected files.

Complete the upstream restore-conflict test initializer so the Rust test
suite can compile.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot added the bug Something isn't working label Sep 30, 2026
@majin1102

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@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.

The lineage-aware retention rule fixes the Update regression while preserving projected-file pruning and commit-time carrier validation. Local manifest and end-to-end spill regressions passed.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 30, 2026
@Xuanwo
Xuanwo merged commit ecb388f into lance-format:main Sep 30, 2026
40 checks passed
BubbleCal added a commit that referenced this pull request Oct 8, 2026
## Problem

Spilled row lineage (#9250) is about to be declared stable. The tests in
`rust/lance/src/dataset/rowids/spill.rs` each pin how one write places
lineage, but nothing checks what a sequence of later operations does to
lineage that is already spilled. That is where it has broken: #9623
fixed an update that dropped a fragment's lineage-only file because no
schema field lived in it, and none of the existing tests caught it.

## What changed

Adds `spilled_lineage_reads_like_inline_lineage`, a differential test in
`rust/lance/src/dataset/rowids/spill.rs`. Each scenario runs the same
steps on two tables: one that spills every sequence (inline budget 0)
and one that keeps them inline, as released builds do. After every step
it asserts that:

- every row has the same row id, created-at and last-updated-at version
on both tables, and keys stay unique;
- both tables validate, and `take_rows` by row id returns the right
rows;
- a filter on `j` returns the same rows, through the zone map and the
fragment reuse index where a scenario builds them;
- the spilled table sets the spilled-lineage feature flag exactly when a
fragment spills, and the inline table never spills.

At the end both tables are reopened cold and every version they keep is
compared.

The 18 scenarios cover:

- consecutive updates, deletes and appends;
- upserts and in-place column patches through merge_insert;
- add, cast and drop column, `Dataset::merge` and `DataReplacement`;
- reencode, binary-copy and deferred-remap compaction, the last with a
zone map so a fragment reuse index is written;
- a compaction racing an append or a delete, and an update racing a
compaction;
- restore, cleanup, shallow and deep clone, and branches.

A compaction whose fragments receive a concurrent delete loses with a
retryable conflict on both tables. That is existing behavior; the
scenario asserts it and checks that both tables still agree afterwards.

## Validation

- All 54 tests in `dataset::rowids::spill` pass. Each new case takes at
most 0.43 s in a debug build, including process startup.
- Reverting the fix from #9623 in `manifest_build.rs` makes all 18
scenarios fail with the error that PR describes.
- `cargo fmt --all -- --check` and `cargo clippy --all --tests --benches
-- -D warnings` pass.

Run on an x86 Linux VM (r8i.8xlarge).

## Limitations

Not covered: overwrite, merge_insert racing other writes, remote object
stores (the scenarios use the local filesystem), spilling at the default
200 KiB budget (every scenario uses budget 0), and the Python and Java
bindings.

Refs #9250

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants