Skip to content

feat: allow FRI to be used with stable row IDs - #9514

Merged
westonpace merged 10 commits into
mainfrom
feat/defer-index-remap-stable-row-ids
Oct 5, 2026
Merged

westonpace merged 10 commits into
mainfrom
feat/defer-index-remap-stable-row-ids

Conversation

@westonpace

@westonpace westonpace commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Enables defer_index_remap compaction on stable-row-ID datasets. Compaction captures pre-rewrite addresses and writes a fragment reuse index, and address-domain indexes (ZoneMap, BloomFilter) follow their data instead of losing coverage. Compaction refuses to defer while a row-id-domain index is present; the compatibility rules from #9120 cover index creation and publishing.


Stack created with GitHub Stacks CLI • Give Feedback 💬

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 23, 2026
@westonpace
westonpace force-pushed the feat/defer-index-remap-stable-row-ids branch from c61d2ac to e62a52d Compare September 23, 2026 17:07
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 23, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 23, 2026
@westonpace
westonpace force-pushed the feat/defer-index-remap-stable-row-ids branch from ab85561 to 4189d7c Compare September 23, 2026 19:07
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 23, 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.

The compaction cost raised earlier is fixed: eager stable-row-ID rewrites skip unused address capture, and deferred rewrites build the lookup from only the task's source fragments. The stable-row-ID/FRI guard still rejects row-ID-domain indexes across planning, commit, and concurrent rebase paths. Focused compaction and race tests pass.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 23, 2026
westonpace and others added 9 commits September 30, 2026 14:46
Compaction refused `defer_index_remap` on a stable-row-id dataset on the
grounds that stable row ids need no remapping. That holds for the
row-id-domain indices, but not for the address-domain ones: a zone map or
bloom filter is built over `_rowaddr`, and a rewrite moves every address it
stores. With nothing to repair those addresses, the rewritten fragments were
dropped from such an index's coverage and the scanner fell back to a full
scan -- correct answers, but the index stopped earning its keep.

Allow the two together so the fragment-reuse index can carry the repair:

- Capture row addresses whenever a deferred remap is requested rather than
  only when row ids are unstable.
- Rechunk stable row ids *and* resolve the captured addresses in the rewrite
  task. These sat in mutually exclusive branches, so capturing addresses
  would otherwise skip `rechunk_stable_row_ids`. Stable row ids are captured
  sequence-style, so only the row-id index knows the address each one sat at.
- Let an address-domain index follow its data to the new fragments when the
  commit carries an FRI, instead of dropping the rewritten fragments.

Narrow the rejection rather than removing it. An FRI is applied to every
index on load, and with stable row ids the two domains diverge: a stable row
id is numerically indistinguishable from an address into fragment 0, so an
FRI applied to a btree would silently rewrite valid row ids rather than fail.
The two therefore cannot coexist on a stable-row-id dataset, and both sides
now refuse to create the pair:

- Compaction rejects a deferred remap while a row-id-domain index is present,
  at the plan boundary and again at the commit boundary, since a caller may
  supply its own planner or commit a plan made before the index existed.
- `create_index` rejects a row-id-domain index while a non-empty FRI is
  present. An unclassifiable type is refused rather than allowed.

Both classifiers treat an unknown type as row-id-domain, so a type missing
from either list costs a refused operation, never silent corruption.

This restriction drops out once every index stores row addresses.

Co-Authored-By: Claude Opus 5 <[email protected]>
#9120 added a publication-time check for fragment reuse indices on stable
row id datasets that rejects the same row-id-domain index combination.
The duplicate gate fired first with a different error and broke its tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KqTXnUMz52CMzSjmDnutf6
@westonpace
westonpace force-pushed the feat/defer-index-remap-stable-row-ids branch from 4189d7c to 3b936b1 Compare September 30, 2026 16:45
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 30, 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.

The publication validation merged in #9120 safely replaces the removed guard: it checks the final index list after rebase and rejects incompatible indexes. Focused tests pass for both commit orderings, including disjoint coverage, and for indexed query results before and after deferred remapping. Eager stable-row-ID compaction still skips unused address capture, and deferred lookup stays scoped to the rewritten fragments. FRI with stable row IDs remains gated to debug builds.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 30, 2026
#9120 already refuses creating a row-id-domain index on a stable row id
dataset that carries a fragment reuse index. The test now matches that
error's wording.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KqTXnUMz52CMzSjmDnutf6
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 30, 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.

The shared compatibility rules merged in #9120 safely replace the removed creation guard. Row-ID indexes remain refused, while focused tests pass for typed and generic ZoneMap requests and BloomFilter creation after deferred compaction. Final-list publication validation still rejects incompatible combinations after rebase. Deferred compaction retains address-index coverage with lookups scoped to source fragments; eager stable-row-ID compaction skips unused address capture. FRI with stable row IDs remains gated to debug builds.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 30, 2026
@westonpace
westonpace merged commit 50e7032 into main Oct 5, 2026
39 checks passed
@westonpace
westonpace deleted the feat/defer-index-remap-stable-row-ids branch October 5, 2026 16:52
brendanclement added a commit to brendanclement/lance that referenced this pull request Oct 5, 2026
Merge main after lance-format#9514. Preserve its index coverage and conflict checks alongside metadata-based address recording, index-free mappings, and distributed commit handling. Update the race regression for the earlier conflict and adapt the new resolver test to the FRI base field.
westonpace added a commit that referenced this pull request Oct 9, 2026
…vening changes

Rebasing this branch onto the 78 commits main gained in the meantime
surfaced test and fixture code that assumed BTree still trains from
row ids -- true when that code was written on main, but no longer
true once this branch's migration lands on top of it. None of these
were textual merge conflicts; they only showed up as test failures.

- `BTreeMemIndexPlugin::training_criteria()` (added by #9803's
  pluggable-mem-wal-index refactor) declared `.with_row_id()`, but
  `to_training_batches()` already emits `_rowaddr`. The new
  declared-vs-actual validation `build_scalar_index` gained (also from
  #9803) now catches that mismatch. Same root cause, two test
  fixtures: `index::create::tests::test_range_based_btree_index_create`
  and `index::frag_reuse_reader::tests::fixture_with_index` fed
  BTree a row-id-declared stream via the generic `preprocessed_data()`
  helper despite already scanning row addresses; both now call
  `preprocessed_stream` with the correct criteria directly.

- `test_row_id_index_creation_racing_defer_index_remap` (added by
  #9514, which allows FRI with stable row ids) exercised a row-id-domain
  BTree index racing a concurrently-committed FRI -- exactly the danger
  this migration exists to close. BTree can no longer illustrate that
  race on a stable-row-id dataset, so the test now uses Bitmap, which
  still stores row ids directly on this branch.

- `test_merge_insert_key_only_concurrent_write`'s compaction case
  updated its expectations: compaction physically rewrites a fragment,
  and an address-domain index can no longer cover the result (the same
  invariant `test_addr_domain_index_does_not_cover_rewritten_update_fragment`
  already covers for ZoneMap/BloomFilter/FM). The in-place patch that
  used to write zero files now correctly falls back to a real rewrite
  to keep the "id" BTree index's coverage consistent, which the test
  now asserts instead of the stale zero-file expectation.

Verified with a side-by-side worktree on plain origin/main: every test
touched here passes there unmodified, confirming the failures were
purely this rebase's interaction with main's intervening work, not
pre-existing breakage.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
westonpace added a commit that referenced this pull request Oct 14, 2026
…vening changes

Rebasing this branch onto the 78 commits main gained in the meantime
surfaced test and fixture code that assumed BTree still trains from
row ids -- true when that code was written on main, but no longer
true once this branch's migration lands on top of it. None of these
were textual merge conflicts; they only showed up as test failures.

- `BTreeMemIndexPlugin::training_criteria()` (added by #9803's
  pluggable-mem-wal-index refactor) declared `.with_row_id()`, but
  `to_training_batches()` already emits `_rowaddr`. The new
  declared-vs-actual validation `build_scalar_index` gained (also from
  #9803) now catches that mismatch. Same root cause, two test
  fixtures: `index::create::tests::test_range_based_btree_index_create`
  and `index::frag_reuse_reader::tests::fixture_with_index` fed
  BTree a row-id-declared stream via the generic `preprocessed_data()`
  helper despite already scanning row addresses; both now call
  `preprocessed_stream` with the correct criteria directly.

- `test_row_id_index_creation_racing_defer_index_remap` (added by
  #9514, which allows FRI with stable row ids) exercised a row-id-domain
  BTree index racing a concurrently-committed FRI -- exactly the danger
  this migration exists to close. BTree can no longer illustrate that
  race on a stable-row-id dataset, so the test now uses Bitmap, which
  still stores row ids directly on this branch.

- `test_merge_insert_key_only_concurrent_write`'s compaction case
  updated its expectations: compaction physically rewrites a fragment,
  and an address-domain index can no longer cover the result (the same
  invariant `test_addr_domain_index_does_not_cover_rewritten_update_fragment`
  already covers for ZoneMap/BloomFilter/FM). The in-place patch that
  used to write zero files now correctly falls back to a real rewrite
  to keep the "id" BTree index's coverage consistent, which the test
  now asserts instead of the stale zero-file expectation.

Verified with a side-by-side worktree on plain origin/main: every test
touched here passes there unmodified, confirming the failures were
purely this rebase's interaction with main's intervening work, not
pre-existing breakage.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants