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 <[email protected]>
This commit is contained in:
Ludovic MarieandClaude Opus 5.5 committed 2026-10-25 20:13:36 +01:00
1 parent 8177a6f450
commit 4513af8995
1 file changed
+11 -1
+11 -1
View File
@@ -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();
}
}