From c3dd9c5b06e95f5fc8f7c5aa81f068437c5bc4e8 Mon Sep 17 00:00:00 2001 From: Dodothereal <129273127+Dodothereal@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:08:32 +0100 Subject: [PATCH] test(storage-sqlite): wait for restore slot to be freed after copy finishes Fixes #872. In a_running_restore_holds_its_slot_and_is_not_listed_dead_by_its_heartbeat, wait_for_copy returns as soon as the target table status is committed to ACTIVE. The job claim is dropped slightly later when the task cleans up, so an immediate check on engine.job_slots.holds(&slot) can see the slot still held. Wait with a 30s deadline matching the pattern used in the same test module. --- crates/storage-sqlite/src/backup.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/storage-sqlite/src/backup.rs b/crates/storage-sqlite/src/backup.rs index 8fa162aff..70ab68a4f 100644 --- a/crates/storage-sqlite/src/backup.rs +++ b/crates/storage-sqlite/src/backup.rs @@ -5971,10 +5971,14 @@ mod restore_tests { wait_for_copy(&engine, &desc.table_id).await, "the copy finishes" ); - assert!( - !engine.job_slots.holds(&slot), - "the slot is freed with the claim when the copy ends" - ); + let deadline = tokio::time::Instant::now() + Duration::from_secs(30); + while engine.job_slots.holds(&slot) { + assert!( + tokio::time::Instant::now() < deadline, + "the slot is freed with the claim when the copy ends" + ); + tokio::time::sleep(Duration::from_millis(10)).await; + } // The state a stopped process leaves: no slot, an aged RUNNING // record. Listed.