Skip to content

fix(index)!: exclude deleted addresses during segment maintenance - #10418

Merged
Xuanwo merged 2 commits into
mainfrom
yang/srid-stack-maintenance
Oct 30, 2026
Merged

Xuanwo merged 2 commits into
mainfrom
yang/srid-stack-maintenance

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Index segment maintenance can retain deleted addresses, and combining deletion vectors with overlays can reintroduce stale entries. Filter address-domain segments by fragment coverage and exact deletion offsets, then retain overlay exclusions. Column rewrites also compare field IDs without converting reserved negative IDs to unsigned values.

Extracted from #10152 as layer 1 of its six-PR stack. Base: main. This layer can land independently; the following layers cover cache support, BTree lookup, Dataset lookup, SRID creation, and bounded capture.

Validation at e05d942ac: 1,631 scalar-index tests, 75 append/maintenance tests, 12 overlay/deletion cases and six reserved-field cases passed. Full workspace Clippy, formatting and commit hooks passed. Two existing scalar tests remain ignored.

BREAKING CHANGE: OldIndexDataFilter gains RowAddresses; downstream exhaustive matches need another arm.

Review and merge order: #10418 → #10419 → #10420 → #10421 → #10152 → #10422.

Keep overlay exclusions when deletion vectors are present and preserve signed reserved field IDs during column rewrites. Extracted from #10152 with matching regression coverage.

BREAKING CHANGE: OldIndexDataFilter gains a RowAddresses variant; downstream exhaustive matches need another arm.

@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 repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 28, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Oct 28, 2026
Xuanwo added a commit that referenced this pull request Oct 29, 2026
## Why

Scalar and FTS query paths independently reconstructed a segment's
current fragment coverage and live-row mask from index metadata. That
made provenance, translated coverage, deletion handling, and row-domain
choices easy to drift.

## What changed

- Add an internal `SegmentCoverage` that resolves query coverage once
through `FriQueryPlan` (or the query listing when no tagged translation
is needed) and obtains live stable row IDs through `DatasetPreFilter`.
- Reuse it for scalar segment unions/lookups and FTS segment opens.
- Keep address-domain hits, non-stable-row-ID tables, and single-segment
indexes on the existing no-filter path.
- Refuse missing or unavailable FRI coverage instead of treating it as
empty. No persistent format or cross-index trait is added.

## Boundaries

- Maintenance and append filtering remain unchanged; #10418 owns the
adjacent old-data and address-deletion semantics.
- Consolidating field-rewrite withdrawal is left separate because it
overlaps #10345's dependency-field changes and is not a small
behavior-preserving change.
- #10001 also moves the same scalar-local coverage implementation for
its hybrid-prefilter work; this PR centralizes FRI-derived coverage and
shares it with FTS, so review/merge order should be coordinated. Do not
stack either branch.

## Verification

Validated at `54e33ff04d43f28f446d7a01e274fad0cb65a43d` with the
repository toolchain `1.98.1` after removing an ambient
`RUSTUP_TOOLCHAIN=1.99.1` override:

- `cargo fmt --all -- --check`
- `cargo clippy --all --tests --benches -- -D warnings`
- 2 segment-coverage unit tests
- 27 scalar-logical tests
- 2 FTS stable-row-ID stale-posting cases
- 274 FRI/tagged-history tests

The full workspace test suite was not run.
@BubbleCal
BubbleCal requested a review from wjones127 October 29, 2026 13:13
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 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.

Deleted-address and overlay exclusions still compose correctly after remapping, and covering-field invalidation is preserved. Sparse exclusions avoid enumerating live rows, and this maintenance layer can land independently of SRID index creation.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 30, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved after reviewing the final head and complete CI. Exact deleted-address filtering is applied after address remapping, overlay exclusions remain additive, and reserved field IDs are compared without unsigned aliasing.

@Xuanwo
Xuanwo merged commit a57dabd into main Oct 30, 2026
41 checks passed
@Xuanwo
Xuanwo deleted the yang/srid-stack-maintenance branch October 30, 2026 07:35
Xuanwo added a commit that referenced this pull request Nov 11, 2026
Bring the accepted UInt64 exact-lookup layer onto current main. Main already
carries the final squashed #10418 segment-maintenance and #10419 prepared-key
implementations plus the later ordered-search and cache-metrics work, so the
historically stacked copies of those commits are dropped in favor of main's
resolved code.

Conflicts resolved as:
- rust/lance-core/src/cache/{backend,mod,quick}.rs: take main. The branch-side
  copies were byte-identical to the pre-squash #10419 commits and this layer
  does not touch the cache crate.
- rust/lance-index/src/scalar/btree.rs: keep both module declarations
  (`lookup` from this layer, `ordered` from main) and merge the test imports.
Xuanwo added a commit that referenced this pull request Nov 11, 2026
UInt64 exact-match lookup can route keys directly to regular BTree pages
and reuse a derived mapping within each cached page. This adds that path
with ordered matching for irregular ranges and duplicate values.
Repeated matches expand lazily into bounded batches, and cached pages
are evaluated after one cache access; missing pages retain bounded,
coalesced reads. The specialization is gated on
`results_are_row_addresses && data_type == UInt64`, every other type and
the legacy row-id domain keep the generic path, null keys are dropped
before matching, and repeated physical page ids fall back to whole-query
matching so keys are never lost.

The cached page directory precharges its lazy key slots (roughly `pages
* size_of::<PageCacheKey>()`) so cache admission cannot be outgrown
during initialization; that charge is bounded and paid once per cached
directory rather than per lookup.

This layer changes BTree lookup and its tests only; persistent index
files are unchanged. #10418 and #10419 have already landed, so this
branch is kept current with ordinary merges of `main`. #10421 is a later
layer, not a dependency for this one.

Validation at `373656ccd1208483f09396dbf0bfc3bddac452fc` (cargo 1.98.1,
`ci` profile):

- `cargo fmt --all -- --check` — clean
- `cargo test --profile ci -p lance-index --lib scalar` — 2400 passed, 0
failed, 2 ignored (both pre-existing and unrelated)
- `cargo test --profile ci -p lance --lib btree` — 159 passed, 0 failed
- `cargo test --profile ci -p lance --lib dataset_overlay_index_masking`
— 155 passed, 0 failed, 1 ignored
- `cargo clippy --profile ci --all --tests --benches -- -D warnings` —
clean

Benchmark evidence covers a single UInt64-address workload only (1M
unique keys, 8192 random probes, `release-with-debug`), so it is not a
claim of a universal speedup; the checked-in performance evidence is the
deterministic comparison-count and lazy-batch-size tests. "Cold" there
means `LanceCache::no_cache()`, not cold disk, and historical timings
belong to `41687579f`/`dbff5f8f6` as supplementary data.

Original implementation by @BubbleCal.

---------

Co-authored-by: Xuanwo <[email protected]>
Xuanwo added a commit that referenced this pull request Nov 16, 2026
Resolve the conflicts left by the moved merge-insert modules and by the
prerequisite layers that have since landed on main (#10418, #10419, #10420):
take main's landed content for those files and port the two delete-path row-id
lookups into merge_insert/job.rs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer breaking-change 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