From 4ef5b3e31df32b7dd4012e0e58ad87b4033da537 Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Wed, 2 Sep 2026 16:19:01 +0800 Subject: [PATCH] render: snapshot store temp dir is unique per store (test parallel flake) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests run in parallel inside one process; each GraphSnapshotStore::new() used the same 'oakrender-snapshots-' root, so one test's cleanup() deleted another test's live snapshot — the acquire_rewrite_forces_file_rewrite_on_same_key flake on the 16-core Windows runner (file written, then exists() == false). Append a per-store sequence number to the directory. --- crates/oak-render/src/worker.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/oak-render/src/worker.rs b/crates/oak-render/src/worker.rs index 932c4f099..05e7d05c7 100644 --- a/crates/oak-render/src/worker.rs +++ b/crates/oak-render/src/worker.rs @@ -287,9 +287,23 @@ struct SnapshotEntry { } impl GraphSnapshotStore { - /// Empty store rooted in the process temp directory. + /// Empty store rooted in the process temp directory. The directory is + /// unique per CALLER-subdirectory: tests run in parallel inside one + /// process, and a shared `oakrender-snapshots-` root let one + /// test's `cleanup()` delete another test's live snapshot (the + /// "acquire_rewrite_forces_file_rewrite_on_same_key" flake on the + /// high-core Windows runner — the file existed right after acquire, + /// then vanished). pub fn new() -> Self { - let dir = std::env::temp_dir().join(format!("oakrender-snapshots-{}", std::process::id())); + let dir = std::env::temp_dir().join(format!( + "oakrender-snapshots-{}-{:x}", + std::process::id(), + { + use std::sync::atomic::{AtomicU64, Ordering}; + static SEQ: AtomicU64 = AtomicU64::new(0); + SEQ.fetch_add(1, Ordering::Relaxed) + } + )); let _ = std::fs::create_dir_all(&dir); Self { entries: Mutex::new(HashMap::new()),