Skip to content

feat(mem_wal): pass writer settings and flush build parameters to memtable index plugins - #9805

Merged
jackye1995 merged 1 commit into
lance-format:mainfrom
xuanyu-z:memwal-plugin-contract
Oct 9, 2026
Merged

jackye1995 merged 1 commit into
lance-format:mainfrom
xuanyu-z:memwal-plugin-contract

Conversation

@xuanyu-z

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

Copy link
Copy Markdown
Contributor

Independent of #9804: based on main, and either can merge first.

Why

A memtable index plugin can take no settings from the writer beyond HNSW's own, and every scalar index it hands to the flush is built with the index type's default parameters. A plugin whose in-memory structure or flushed index has tunable settings has no way to receive them.

What changes

  • Writer settings reach any plugin. ShardWriterConfig::index_overrides (with_index_override) carries each index's settings, by index name, as the type its plugin reads through ResolveContext::overrides. The HNSW settings (hnsw_params) feed the same channel; naming one index in both is an error. Each writer passes its own: unlike hnsw_params, these settings are not recorded as writer defaults.
  • A plugin that reads settings checks their type. Settings of a type the plugin does not read stop the writer from opening, instead of falling back to defaults. Settings for an index whose plugin reads none are ignored, as before, and logged.
  • A scalar flush uses the plugin's parameters. MemIndexPlugin::flush_params(spec) gives the parameters for BuildFromGeneration and TrainingData builds; by default these are the index type's default parameters, so the built-in kinds build as before. The writer calls it when it opens, so a plugin rejecting its parameters stops the writer from opening rather than failing a flush.
  • The plugin contract is written down on resolve and flush_params: read settings through ResolveContext::overrides, keep them in the params resolve returns so they reach both the in-memory index and the flush, and so a changed setting is a different index under MemIndexSpec::same_index.

No behaviour of the built-in kinds changes.

Breaking changes

  • ShardWriterConfig gains a public index_overrides field.
  • ResolveContext::overrides returns Result<Option<&P>>; its settings are no longer a public field, and the context is built only by Lance.

Testing

  • Non-default HNSW settings given through index_overrides are the ones the index is built with.
  • Settings of the wrong type stop the writer from opening; settings for a kind that reads none are ignored and the index is maintained; settings named in both channels stop the writer from opening.
  • A B-tree flushed with a non-default zone size records that zone size on disk, both when the index hands over its rows and when the flush reads the generation.
  • A plugin rejecting its flush parameters fails validation.
  • cargo nextest run -p lance passes (5,308 tests); cargo clippy -p lance --all-targets -- -D warnings, cargo doc -p lance with -D warnings and cargo fmt --all -- --check are clean.

@github-actions github-actions Bot added the bug Something isn't working label Oct 8, 2026
@xuanyu-z
xuanyu-z force-pushed the memwal-plugin-contract branch from 6fd542d to eb8013d Compare October 8, 2026 21:10
@xuanyu-z
xuanyu-z force-pushed the memwal-plugin-contract branch from eb8013d to e390b58 Compare October 9, 2026 00:21
@xuanyu-z xuanyu-z changed the title fix(mem_wal): hold memtable index plugins to the interface's contract feat(mem_wal): pass writer settings and flush build parameters to memtable index plugins Oct 9, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Oct 9, 2026
@xuanyu-z
xuanyu-z force-pushed the memwal-plugin-contract branch 9 times, most recently from cb399eb to 9f35bbc Compare October 9, 2026 19:33
@xuanyu-z
xuanyu-z marked this pull request as ready for review October 9, 2026 20:01

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

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 9, 2026
@xuanyu-z
xuanyu-z force-pushed the memwal-plugin-contract branch from 9f35bbc to c781341 Compare October 9, 2026 21:40
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 9, 2026
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 9, 2026
@xuanyu-z
xuanyu-z force-pushed the memwal-plugin-contract branch from c781341 to 1213509 Compare October 9, 2026 22:26
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 9, 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 plugin configuration gap is addressed without changing the built-in index formats.

Please mark this PR with the breaking-change label.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 9, 2026
@jackye1995
jackye1995 merged commit b1bb64b into lance-format:main Oct 9, 2026
xuanyu-z added a commit to lancedb/lancedb that referenced this pull request Oct 12, 2026
## 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
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.

---------

Co-authored-by: XYZhan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 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.

2 participants