From 8b22cef9759943e2a146acde16d6ba0ff01ed827 Mon Sep 17 00:00:00 2001 From: Vishnu Jayavel Date: Tue, 28 Jul 2026 17:32:51 -0700 Subject: [PATCH] [BUG](sysdb): Take write lock in delete_collection delete_collection opened a deferred transaction, so SQLite did not acquire the write lock until the first write. A concurrent create and delete on the same collection name could therefore interleave and lose an update. create_collection already calls begin_immediate for exactly this reason; do the same here. Closes #7375 --- rust/sysdb/src/sqlite.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust/sysdb/src/sqlite.rs b/rust/sysdb/src/sqlite.rs index cd4a8b468d2..a3a10447c0c 100644 --- a/rust/sysdb/src/sqlite.rs +++ b/rust/sysdb/src/sqlite.rs @@ -604,6 +604,12 @@ impl SqliteSysDb { .begin() .await .map_err(|e| DeleteCollectionError::Internal(e.into()))?; + // Match create_collection: a deferred transaction lets a concurrent + // create/delete on the same name lose updates. + self.db + .begin_immediate(&mut *tx) + .await + .map_err(|e| DeleteCollectionError::Internal(e.into()))?; let was_found = self .delete_collection_with_conn(&mut *tx, tenant, database, collection_id, segment_ids)