mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-18 01:32:27 +00:00
## Why Every MemWAL write and read resolves rows by the table's unenforced primary key, but `enable_memwal` accepted a table without one. The spec installed, and every MemWAL `merge_insert` then failed with "table has a MemWAL index but no unenforced primary key" until MemWAL was disabled. Lance's MemWAL initialization doesn't catch it: its key checks pass when there is no key. ## What changes `enable_memwal` refuses a spec on a table with no unenforced primary key, for every sharding mode, before anything is committed. The check runs against the dataset the spec is committed to; a key cannot be removed once set, and an overwrite or restore of the table conflicts with that commit. Servers that install specs through this method get the check too. The Rust doc on `Table::enable_memwal` now states the requirement; the Python and TypeScript docs already did. ## Tests - New `test_enable_memwal_requires_primary_key` (Rust and Python): unsharded, bucket and identity specs are all refused without a key, a refused spec leaves nothing installed, and the same table accepts a spec once a key is set. The Rust test fails with the check disabled. - Tests that installed a spec on a table without a key now declare one first (6 Rust, 3 Python). - `cargo nextest run -p lancedb --features remote --lib`: 1529 passed. `cargo clippy -p lancedb --features remote --tests --examples -- -D warnings` and `cargo fmt --check` are clean; no integration test or example installs a spec. - Python: `test_memwal_spec.py` and `test_merge_insert_lsm.py`, 43 passed; `ruff format` and `ruff check` are clean.