From f5504ff4048c02a9bdd6cefaec205f7aef7c601f Mon Sep 17 00:00:00 2001 From: ldm0 Date: Sat, 7 Nov 2026 04:00:02 +0800 Subject: [PATCH] test(indexeddb): keep held database barriers under guard control Release synthetic blocking work only when its guard is dropped, including during unwinding. Exercise real maintenance timers with flat SQLite files so unrelated catalog publication does not consume the observation window, and assert that the held owner remains live. --- moli-indexeddb/src/sqlite/service/tests.rs | 5 ++++- .../service/tests/catalog_tests/idle_tests.rs | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/moli-indexeddb/src/sqlite/service/tests.rs b/moli-indexeddb/src/sqlite/service/tests.rs index dc60e6db132..f4cb44c61ea 100644 --- a/moli-indexeddb/src/sqlite/service/tests.rs +++ b/moli-indexeddb/src/sqlite/service/tests.rs @@ -1418,7 +1418,10 @@ fn hold_database(client: &DatabaseClient) -> HeldDatabase { .submit( move |_| { entered.send(()).unwrap(); - blocked.recv_timeout(Duration::from_secs(10)).unwrap(); + // The guard owns this barrier. A watchdog here could release + // the owner while a slow test still relies on it being held. + // Callers bound their observations and release on unwind. + blocked.recv().unwrap(); Ok(()) }, |_| {}, diff --git a/moli-indexeddb/src/sqlite/service/tests/catalog_tests/idle_tests.rs b/moli-indexeddb/src/sqlite/service/tests/catalog_tests/idle_tests.rs index a2c04c061dd..22e3bf6f23e 100644 --- a/moli-indexeddb/src/sqlite/service/tests/catalog_tests/idle_tests.rs +++ b/moli-indexeddb/src/sqlite/service/tests/catalog_tests/idle_tests.rs @@ -414,8 +414,11 @@ fn completed_maintenance_before_blocking_does_not_count_as_pending() { fn assert_later_rounds_progress_with_blocked_database(prior_check: bool) { let directory = Directory::new(); - let mut service = Service::on_disk(directory.0.join("idb-lite"), config()).unwrap(); - let slow = resolve(&service, OWNER, "a-held"); + // This checks the real maintenance timer and per-database FIFOs. Flat disk + // files avoid putting unrelated catalog directory syncs inside the held + // interval; catalog publication and recovery have their own tests. + let mut service = Service::new(config()).unwrap(); + let slow = open(&service, "a-held", directory.location("a-held.sqlite")); if prior_check { slow.owner .maintain(Instant::now()) @@ -452,7 +455,7 @@ fn assert_later_rounds_progress_with_blocked_database(prior_check: bool) { } // This database did not exist in the blocked round. Its reclamation must // come from a subsequent real timer round, with no manual clock advance. - let fast = resolve(&service, OWNER, "b-later"); + let fast = open(&service, "b-later", directory.location("b-later.sqlite")); let deadline = Instant::now() + Duration::from_secs(6); while physical_connection(&fast) { assert!( @@ -466,5 +469,9 @@ fn assert_later_rounds_progress_with_blocked_database(prior_check: bool) { initial_submissions + 1, "only one check may wait behind held SQL" ); + assert!( + !slow.is_closed(), + "the held owner must remain live until the test releases it" + ); drop(held); }