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.
This commit is contained in:
ldm0
2026-11-07 10:55:09 +08:00
committed by Donough Liu
parent db58d0fd7a
commit f5504ff404
2 changed files with 14 additions and 4 deletions
+4 -1
View File
@@ -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(())
},
|_| {},
@@ -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);
}