fix(dataset): stop the fragment-reuse index blocking row id migration - #9099
Open
LuciferYang wants to merge 1 commit into
Open
fix(dataset): stop the fragment-reuse index blocking row id migration#9099LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
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.
Contributor
There was a problem hiding this comment.
✅ 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_reusefirst, 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 rejectsdefer_index_remapon 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_indicescompacts withdefer_index_remap: true, drops the user index, asserts__lance_frag_reuseis 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_indexstill passes, so a user index continues to block.