Skip to content

fix(index): avoid fragment reuse cache deadlock - #54

Merged
amunra merged 1 commit into
release-10.0.0from
adam/fri-deadlock-r10
Aug 27, 2026
Merged

amunra merged 1 commit into
release-10.0.0from
adam/fri-deadlock-r10

Conversation

@amunra

@amunra amunra commented Aug 27, 2026

Copy link
Copy Markdown

Related

What

open_frag_reuse_index loads the fragment-reuse index metadata, then its cache-miss loader calls load_index for the same UUID. load_index delegates to load_indices, which probes the same frag_reuse/{uuid} cache key. moka holds the waiter's write lock across the init future, so the inner call parks on a read against the outer write guard: a permanent, zero-CPU deadlock.

It needs cache pressure to reach, since a cached entry never runs the loader — which is why it survives normal use and strikes when the index cache is small or under eviction. The fix uses the metadata already loaded before entering the cache loader, instead of re-reading it.

This is live on v10.0.0.

Testing

cargo test -p lance --lib test_open_frag_reuse_index_with_zero_capacity_cache passes.

Upstream's test provisions a Session with MokaCacheBackend::no_cache(), so the loader always runs, and wraps the call in a 5s timeout. Confirmed it is not vacuous: reverting the two production lines makes it fail with

panicked at rust/lance/src/index.rs:4749:10:
opening the fragment reuse index deadlocked: Elapsed(())

cargo clippy -p lance --lib -- -D warnings and cargo fmt --check clean.

Compatibility

No API or format change. Removes a hang; nothing that previously succeeded behaves differently.

## Summary

- use the fragment-reuse metadata already loaded before entering the
cache loader
- prevent the loader from recursively probing its own single-flight
cache key
- add a zero-capacity Moka cache regression test for the eviction
fallback

## Root cause

`open_frag_reuse_index` loaded the matching metadata, then its
cache-miss loader called `load_index` for the same UUID. `load_index`
delegates to `load_indices`, which probes the same fragment-reuse cache
key. Under eviction pressure, the single-flight leader therefore waited
on its own in-flight load indefinitely.

## Validation

- `cargo test -p lance
test_open_frag_reuse_index_with_zero_capacity_cache -- --nocapture`
- `cargo test -p lance test_load_indices -- --nocapture`
- `cargo fmt --all`
- `cargo clippy --all --tests --benches -- -D warnings`

Fixes lance-format#8619

<!-- lance-gatekeeper-fix:v1 agent=04eb7f91260e98b8eaa60312dbe80b06
generation=1 -->

Co-authored-by: Gatefixer <312823363+lance-gatefixer[bot]@users.noreply.github.com>
(cherry picked from commit ff4584f)
@amunra
amunra merged commit d299bbd into release-10.0.0 Aug 27, 2026
36 checks passed
@amunra amunra added lance fork 10.0.0 Landed on the release-10.0.0 fork line upstream backport Already upstream, on a release later than ours labels Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lance fork 10.0.0 Landed on the release-10.0.0 fork line upstream backport Already upstream, on a release later than ours

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants