diff --git a/src/backfill/sparse.rs b/src/backfill/sparse.rs index 8189133..a71bd4e 100644 --- a/src/backfill/sparse.rs +++ b/src/backfill/sparse.rs @@ -439,6 +439,12 @@ async fn persist_sparse_backfill( let mut collection_counts: HashMap = HashMap::new(); let mut txn = DbTxn::new(db); + // permanent mode locks before the existing-head snapshot so a live + // write or operator redaction cannot invalidate the diff. ephemeral + // mode has no heads and therefore no shared record state to lock. + if !app_state.ephemeral { + txn.hold_repo_write_lock(&did); + } let prefix = keys::record_prefix_did(&did); let mut existing_cids: HashMap<(SmolStr, DbRkey), SmolStr> = HashMap::new();