From 4513af89954872409e1f02909633789c6293a5a9 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 20:13:36 +0100 Subject: [PATCH] horizon-server: the lock test waits for a fork-held descriptor to close Tests in the same binary spawn processes (tar, the engine); between fork and exec the child holds a copy of every open descriptor, the lock's too, so relocking right after drop could see WouldBlock. Seen twice on CI (#1833, #1895). Co-Authored-By: Claude Opus 5.5 --- crates/horizon-server/src/supervisor.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/horizon-server/src/supervisor.rs b/crates/horizon-server/src/supervisor.rs index 4de011362..f2e811700 100644 --- a/crates/horizon-server/src/supervisor.rs +++ b/crates/horizon-server/src/supervisor.rs @@ -849,7 +849,17 @@ mod tests { let first = lock(&dir).unwrap(); assert!(lock(&dir).unwrap_err().contains("already running")); drop(first); - lock(&dir).unwrap(); + // A process another test spawns holds a copy of the lock's descriptor between its fork and exec: + // the lock comes back once that child has exec'd. + let mut again = lock(&dir); + for _ in 0..50 { + if again.is_ok() { + break; + } + std::thread::sleep(std::time::Duration::from_millis(20)); + again = lock(&dir); + } + again.unwrap(); std::fs::remove_dir_all(&dir).unwrap(); } }