fix: reject CreateIndex when concurrent RewriteColumns modified indexed fields#16
Merged
zehiko merged 1 commit intorelease-3.0.0from Apr 13, 2026
Merged
Conversation
…ed fields
When a MergeInsert updates fewer columns than the dataset schema, Lance
takes the RewriteColumns path — rewriting column data files in-place
within the same fragment (same fragment ID, same row IDs, different
column values). If optimize_indices concurrently builds a new index from
the pre-update data and commits it, the conflict resolver in
check_create_index_txn unconditionally allows it ("row ids are still
valid"). The resulting index has stale values for the rewritten columns.
Since the fragment ID didn't change, effective_fragment_bitmap does not
filter it out, and the stale index data is authoritative. Indexed scans
then return incorrect results while full scans return correct data.
The fix: when CreateIndex encounters a concurrent Update with
RewriteColumns mode, check whether the modified fields overlap with the
new index's fields AND whether the rewritten fragments are in the
index's fragment_bitmap. If so, return a retryable conflict, forcing
optimize_indices to re-read the updated data.
RewriteRows (full-column upsert) and Delete operations remain
unconditionally allowed — they remove the old fragment entirely, so
effective_fragment_bitmap naturally filters out stale entries.
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.
What
When a MergeInsert updates fewer columns than the dataset schema, Lance takes the
RewriteColumnspath — rewriting column data files in-place within the same fragment (same fragment ID, same row IDs, different column values). Ifoptimize_indicesconcurrently builds a new index from the pre-update data and commits it, the conflict resolver incheck_create_index_txnunconditionally allows it ("row ids are still valid"). The resulting index has stale values for the rewritten columns.Since the fragment ID didn't change,
effective_fragment_bitmapdoes not filter it out, and the stale index data is authoritative. Indexed scans then return incorrect results while full scans return correct data.The fix: when
CreateIndexencounters a concurrentUpdatewithRewriteColumnsmode, check whether the modified fields overlap with the new index's fields AND whether the rewritten fragments are in the index'sfragment_bitmap. If so, return a retryable conflict, forcingoptimize_indicesto re-read the updated data.RewriteRows(full-column upsert) andDeleteoperations remain unconditionally allowed — they remove the old fragment entirely, so effective_fragment_bitmap naturally filters out stale entries.Upstream PR: lance-format#6493
Testing done