Skip to content

fix(dataset): stop the fragment-reuse index blocking row id migration - #9099

Open
LuciferYang wants to merge 1 commit into
lance-format:mainfrom
LuciferYang:fix/srid-migration-system-index
Open

fix(dataset): stop the fragment-reuse index blocking row id migration#9099
LuciferYang wants to merge 1 commit into
lance-format:mainfrom
LuciferYang:fix/srid-migration-system-index

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Closes #9081.

The migration guard rejected any dataset with committed indices, including the fragment-reuse index that compaction registers under defer_index_remap. A user who compacted that way and later dropped every index they created was told to drop __lance_frag_reuse first, an internal bookkeeping index they never made.

Ignoring it in the guard is only safe if it does not survive the migration, and on its own it does. It maps old row addresses to new ones, and the read path attaches the remapper to every index it opens (rust/lance/src/index/scalar.rs:575) without checking whether the dataset uses stable row ids. Since the migration issues ids from 0, which is exactly fragment 0's old address range, a survivor rewrites freshly issued row ids as if they were addresses and the affected rows disappear from indexed queries. So the migration drops it from the manifest it builds. Nothing needs it afterwards, since compaction rejects defer_index_remap on a stable-row-id dataset (rust/lance/src/dataset/optimize.rs:754).

The guard keys on the fragment-reuse index by name rather than on is_system_index, which also covers the MemWAL index. MemWAL tracks unflushed regions and row visibility, and I have no argument that migrating past a live one is safe, so it keeps blocking, as it does today.

Testing

test_migrate_to_stable_row_ids_ignores_system_indices compacts with defer_index_remap: true, drops the user index, asserts __lance_frag_reuse is the only one left, and migrates. It then asserts no index survived, rebuilds the scalar index, and checks that a lookup through it finds the row it covers.

Both halves fail without their respective change: with the guard unrelaxed the migration errors naming that index, and with the removal disabled the test reports got ["__lance_frag_reuse"] and the post-migration lookup returns 0 rows instead of 1.

test_migrate_to_stable_row_ids_blocked_by_index still passes, so a user index continues to block.

The migration guard rejected any dataset with committed indices, including
the fragment-reuse index that compaction registers under deferred index
remap. A user who compacted that way and later dropped every index they
created was told to drop `__lance_frag_reuse` first, an internal bookkeeping
index they never made.

Ignoring it in the guard is only safe if it does not survive the migration.
It maps old row addresses to new ones, and the read path attaches it to
every index it opens without checking whether the dataset uses stable row
ids, so a survivor rewrites freshly issued row ids as if they were
addresses: a row whose new id lands in the old address range disappears
from indexed queries. The migration therefore drops it from the manifest it
builds. Nothing needs it afterwards, since compaction rejects deferred
index remap on a stable-row-id dataset.

Every other index still blocks the migration, the MemWAL index included.
Only the fragment-reuse index is known to be discardable.
@github-actions github-actions Bot added the bug Something isn't working label Sep 9, 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.

Removing the obsolete remapper at the migration boundary is the right contract: stable-row-ID datasets never need deferred address remapping, while user indices and MemWAL remain blocked. The regression covers both successful migration and a rebuilt indexed lookup, preventing a carried remapper from silently hiding rows.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 9, 2026
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: stable row id migration is blocked by the fragment-reuse system index

2 participants