RolloutStore::dataset should be interior-mutable so merge/compact can refresh the handle without an exclusive lock
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 42/100
Direzione di ricerca
Inizia da crates/lance-context-core/src/rollout_store.rs e analizza la ownership di Dataset e i suoi circa 52 punti di chiamata, quindi esamina i percorsi esistenti di merge e compact. Confronta gli approcci proposti con handle condivisi con l’attuale flusso di locking ed esegui crates/lance-context-core/tests/wal_merge_concurrency.rs. Il lavoro è completato quando merge, compact e schema evolution accettano self senza write lock dello store, con un nuovo test di concorrenza compact-versus-append.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Context
Follow-up to the WAL-merge write-lock stall (a merge held the store's write lock for ~17s, blocking every concurrent add). That is being fixed by splitting the merge into a &self prepare phase (seal + read every flushed generation — the expensive part) and a short &mut self commit phase, so callers hold the exclusive lock only for the commit.
That fix removes the stall, but it works around the underlying constraint rather than removing it. This issue tracks removing it.
The constraint
RolloutStore owns its Dataset by value:
// crates/lance-context-core/src/rollout_store.rs
pub struct RolloutStore {
dataset: Dataset,
...
}
Dataset's mutating operations are &mut self not because they mutate in place, but because they rebind the whole struct at the end:
// lance-7.0.0/src/dataset.rs:919
pub async fn append(&mut self, ...) -> Result<()> {
let new_dataset = InsertBuilder::new(...).execute_stream(...).await?;
*self = new_dataset; // whole-struct replacement
Ok(())
}
checkout_latest, add_columns and compact_files follow the same pattern. So the &mut requirement propagates outward — append_merged_batches → commit_merge → merge_own_shard_if_ready → cleanup_own_shard → and finally to every caller, which must take RwLock::write().
The result is that an exclusive lock is required for reasons that have nothing to do with mutual exclusion of the work itself. A merge appends to the base table and drains sealed generations; add writes the active memtable. They touch disjoint data. The lock exists only to satisfy the borrow checker.
Why this still bites after the split fix
The prepare/commit split shrinks the exclusive section but does not eliminate it, and it pushes the lock discipline onto callers:
- Callers must remember the two-phase dance; a caller that just calls
cleanup_own_shard()under one write lock silently reintroduces the stall. That is an easy mistake to make and there is no compile-time signal. - The commit phase still blocks appends for the duration of the base-table append. Small compared to reading N generations from object storage, but non-zero and proportional to merged data volume.
compact()has the identical shape (compact_files(&mut self.dataset, ...)then a reload) and still takes the write lock for its whole duration.
Proposal
Make the base dataset interior-mutable, e.g.:
dataset: Arc<RwLock<Dataset>>, // or arc_swap::ArcSwap<Dataset>
Then merge, compact, and schema evolution can all take &self, refresh the shared handle when they commit, and never need an exclusive lock on the store. Merge-vs-merge exclusion (which is genuinely needed — two concurrent merges would read the same generations and append them twice) becomes an explicit, narrow mutex rather than a side effect of &mut.
ArcSwap is probably the better fit than RwLock: reads are the overwhelming majority, the value is cheap to clone (every Dataset field is already an Arc), and writers only ever replace the whole value.
Cost
~52 self.dataset call sites in rollout_store.rs, of which only 4 are assignments and 1 is a &mut borrow — the rest are reads (uri(), schema(), manifest(), object_store(), ...). Mechanical, but broad enough that it should not ride along with a targeted stall fix; it deserves its own review and its own soak.
ContextStore and DatagenStore have the same shape and would want the same treatment.
Acceptance
merge,compactand schema evolution take&self.- No caller needs
RwLock::write()on the store to run a background maintenance task. - The existing concurrency tests (
crates/lance-context-core/tests/wal_merge_concurrency.rs) still pass, plus a new one assertingcompactdoes not block appends.
- Lingua principale
- Rust
- Stelle
- 89
- Fork
- 21
- Merge medio
- 2h 6m
- PR unite (30g)
- 435
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lance-format/lance-context
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
lance-format/lance-context#832 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
lance-format/lance-context#378 · 119 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 6/100
lance-format/lance-context#333 · 11 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
lance-format/lance-context#260 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
lance-format/lance-context#214 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lance-format/lance-context
Issue simili
-
comp-rbac
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ClickHouse/ClickHouse#131875 ·
I maintainer di solito rispondono entro 1 giorno
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indicesForse già presa @Borg93 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
lance-format/lance#11117 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
storytold/photocraft#15232 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
forge: fork preflight reads still send `requireCanonical: false`, which Rootstock rejects (-32603)Forse già presa @Ynyesto l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
foundry-rs/foundry#18485 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
bondybondbond/rushcut#238 · 1 commento ·