Skip to content

feat: maintain memtable index kinds from a table's registry - #4477

Merged
xuanyu-z merged 3 commits into
lancedb:mainfrom
xuanyu-z:memtable-index-registry
Oct 12, 2026
Merged

xuanyu-z merged 3 commits into
lancedb:mainfrom
xuanyu-z:memtable-index-registry

Conversation

@xuanyu-z

@xuanyu-z xuanyu-z commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Why

lance-format/lance#9803 makes the MemWAL's memtable index kinds pluggable: a MemIndexRegistry on the writer config decides which base-table index kinds are maintained in memory, so a kind Lance does not build in can be added by registering a plugin. LanceDB opens the MemWAL writer itself for merge_insert, and checks a named maintained set itself, both against Lance's built-ins only. So a kind registered outside Lance could not be named in LsmWriteSpec::with_maintained_indexes, and under "maintain every index" it was skipped.

What changes

  • NativeTable::set_mem_index_registry(registry) sets the memtable index kinds a table maintains. The default is Lance's built-ins, so nothing changes unless a caller sets one. The registry checks a named maintained set (validate_maintained_indexes_with), is recorded on initialize_mem_wal, and goes on the writer config merge_insert opens. lancedb::table re-exports MemIndexRegistry and Lance's plugin traits (mem_index), so a caller needs no direct lance dependency.
  • The LSM vector read no longer checks resident memtables at all, and the carries_vector_index helper goes with it. Lance already compares every row of a memtable whose index can't answer the search, so no rows are missed. It still requires the base vector index to be maintained.

Limits

  • The registry belongs to the table handle. Clones of a handle and its branch handles share it; a handle opened separately starts from the built-ins. Set it before the handle's first LSM write: a writer already open keeps the kinds it opened with.
  • The maintained set is stored with the table but the registry is not. Once a spec names an index only a registered plugin maintains, an LSM write from a handle without that registry is refused with Lance's "no registered plugin maintains" error rather than skipping the index. That includes the Python and Node bindings, which have no way to set a registry yet.
  • Rust only. A registry holds Rust plugin objects, which the Python, TypeScript and Java bindings cannot construct, so they get no setter; their documented behaviour (built-in kinds only) is unchanged.
  • Per-index plugin settings (ShardWriterConfig::index_overrides, from feat(mem_wal): pass writer settings and flush build parameters to memtable index plugins lance-format/lance#9805) are not exposed; writers use each plugin's defaults.

Open decision

Whether the registry should also be settable on the connection, so every table a connection opens carries it. This PR keeps it per table; a connection-level option would sit on top of set_mem_index_registry without changing it.

Depends on

Lance v14.0.0-beta.13, which main already uses. It includes lance-format/lance#9803 and #9805 (pluggable memtable index kinds) and #9857 (flushed generations keep the table's field ids).

Testing

  • lsm_maintains_an_index_kind_from_the_tables_registry: a stand-in plugin maintains the base table's bitmap index as a B-tree. Naming the index is refused without the registry and accepted with it; a separately opened handle without the registry is refused an LSM write. Rows written through merge_insert are found by id before and after the flush. Each generation the shard manifests publish carries a bitmap index on region, and a filter on it is answered through that index.
  • lsm_default_set_maintains_a_registry_kind_created_while_writing: under "maintain every index", a bitmap index created after the writer opened is picked up by that writer and flushed. A clone of the table handle shares the registry.
  • lsm_vector_search_compares_every_row_when_no_resident_index_answers: with a vector plugin that answers no search, LSM vector search still returns the right rows, including a second page.
  • cargo test -p lancedb --features remote --lib passes; cargo clippy -p lancedb --features remote --tests -- -D warnings and cargo fmt --all -- --check are clean.

@github-actions github-actions Bot added enhancement New feature or request Rust Rust related issues labels Oct 7, 2026
@xuanyu-z
xuanyu-z force-pushed the memtable-index-registry branch 6 times, most recently from 4c7e992 to a5402e9 Compare October 10, 2026 00:16
@xuanyu-z
xuanyu-z marked this pull request as ready for review October 10, 2026 00:16

@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 pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Oct 10, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Oct 10, 2026
@xuanyu-z
xuanyu-z force-pushed the memtable-index-registry branch from 969b3bf to b77c0f3 Compare October 10, 2026 01:10
@lancedb-gatekeeper lancedb-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Oct 10, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Oct 10, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Oct 10, 2026

@lancedb-gatekeeper lancedb-gatekeeper 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.

⚠️ Gate recommendation: approve with a non-blocking risk.

The registry reaches validation, MemWAL initialization, and writer creation while preserving built-in defaults. Its handle-local scope is reasonable for runtime plugins; independently opened handles fail explicitly when a named index needs an unavailable plugin. Vector search uses Lance's fallback when a resident index declines a query. The merged lockfile retains the base's updated dependency graph while selecting the required Lance plugin revision. Local validation passed: 1,454 Rust library tests, with one ignored, including plugin maintenance, vector pagination, and remote-client tests.

The remaining risk is the upstream field-ID bug tracked by Lance #9857. I reproduced post-flush null values after a column drop with both the built-in B-tree and the bitmap plugin. The same renumbering path is present in the base dependency, so no registry change is requested here. Until Lance includes that fix, avoid LSM writes after column drops that leave field-ID gaps; the planned dependency release update should include it.

@lancedb-gatekeeper lancedb-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Oct 10, 2026
`NativeTable::set_mem_index_registry` sets the memtable index kinds a table
maintains when it writes through its LSM spec; the default is Lance's
built-ins. The registry validates a named maintained set, is recorded when
MemWAL is initialized, and goes on the writer config `merge_insert` opens.

The LSM read checks that every resident memtable carries the searched
column's index ask by capability: full-text granularities, and the vector
search the memtable will run with the metric left open.
Lance compares every row of a resident memtable whose index cannot answer
a vector search, so the LSM vector read no longer checks resident memtables
for one; it still requires the base vector index to be maintained.

Tests now check exact rows, read generations from the shard manifests,
search each flushed generation through the plugin's index, and cover a
registry kind created after the writer opened under the default set.
Re-export MemIndexRegistry and Lance's plugin traits so callers need no
direct lance dependency, give set_mem_index_registry an example, and link
it from with_maintained_indexes.
@xuanyu-z
xuanyu-z force-pushed the memtable-index-registry branch from e6c781c to e5761bd Compare October 12, 2026 14:31
@lancedb-gatekeeper lancedb-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Oct 12, 2026
@xuanyu-z
xuanyu-z merged commit 25fcfc6 into lancedb:main Oct 12, 2026
30 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Rust Rust related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants