You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
drop_table leaves stale session cache entries — same-URI recreate can panic with "row id missing from index" #3626
Connection::drop_table removes the table's data but does not purge the shared Session caches (dataset metadata cache / index cache) for the dropped table's
URI. When a table is dropped and a new table is re-created under the same
URI, a subsequent mutation (DELETE/UPDATE with stable row ids) can resolve
stale cached metadata belonging to the dropped dataset and panic inside lance:
lance/src/dataset/utils.rs:129: row id missing from index
Why the stale entry survives
The most damaging stale entry is the row-id sequence. Its cache key is
version-less (row_id_sequence/{fragment_id} — RowIdSequenceKey in lance), and
the only namespacing above it is the dataset URI prefix
(GlobalMetadataCache::for_dataset(uri)), which the comment there notes
"prevents collisions between different datasets". It does not prevent collisions
between two generations of the same URI. So after drop + same-URI re-create,
a lookup for row_id_sequence/0 of the new dataset can hit the sequence of the old (dropped) dataset still resident in the shared session, and the mismatch
against the new fragment's physical rows trips the row id missing from index
invariant. (Filed the version-less-key angle separately against lance.)
Reproduction (embedding host, single process, shared session)
CREATE table t (stable row ids), insert rows, COMPACT, DROP TABLE t.
CREATE table t again at the same URI, insert rows.
First DELETE on the new t → panic. Deterministic when the stale entry is
still resident; with concurrent readers priming the cache it reproduces
within a few cycles.
Observed with lancedb 0.31 / lance 8.0.0.
Fix that worked for us
Have the connection own its Session explicitly (ConnectBuilder::session()),
so drop_table can reach both cache layers deterministically.
After the drop, purge both caches by URI prefix — using two
terminator-precise prefixes ({uri}/ and {uri}?) so sibling tables that
share a name prefix (t vs t2, or a query-string variant) are not evicted.
Run the purge unconditionally after the drop attempt (also on the timeout
path), so a timed-out-but-still-progressing drop cannot leave repopulated
stale entries behind.
After the fix: 30/30 drop → re-create → mutate cycles clean (previously panicked
by cycle 3).
Happy to upstream a PR if the approach sounds right — the ideal fix probably
combines this drop-time purge with a version/generation component in lance's
row-id sequence cache key.
Update: as of lance-format/lance#8904 (merged 2026-08-31), IndexMetadataKey now carries the manifest e-tag, closing one of the four gaps #8078's own follow-up note named. RowIdSequenceKey was already fixed by #8078 itself.
The remaining three — TransactionKey, RowIdIndexKey, RowAddrMaskKey — are addressed by lance-format/lance#8916, extending #8904's exact pattern to each. Includes a drop/recreate regression test for TransactionKey (verified it fails without the fix, passes with it) and key-isolation unit tests for all three.
Activity
hellower commentedon Jul 6, 2026
Companion lance issue for the version-less cache key: lance-format/lance#7645
wjones127 commentedon Jul 13, 2026
I think what we need to do is start adding the version + manifest e_tag as part of the prefix, and that will avoid this kind of cache issues on drop.
hellower commentedon Aug 31, 2026
Update: as of lance-format/lance#8904 (merged 2026-08-31),
IndexMetadataKeynow carries the manifest e-tag, closing one of the four gaps #8078's own follow-up note named.RowIdSequenceKeywas already fixed by #8078 itself.The remaining three —
TransactionKey,RowIdIndexKey,RowAddrMaskKey— are addressed by lance-format/lance#8916, extending #8904's exact pattern to each. Includes a drop/recreate regression test forTransactionKey(verified it fails without the fix, passes with it) and key-isolation unit tests for all three.