From 09e72815f284d83012f0b7a3761e1fc891abef1e Mon Sep 17 00:00:00 2001 From: Ajay Thorve Date: Mon, 22 Jun 2026 23:24:53 -0700 Subject: [PATCH] Make generated ids unique across processes new_id derived uniqueness from a millisecond timestamp plus a process-global atomic counter. A process-backed runner spawns a fresh fabric-cli per call, so the counter resets to 1 every time and two concurrent runs in the same millisecond produced identical ids (runtime_id, invocation_id, and the artifact roots derived from them). Include the process id, which the OS keeps distinct across concurrently running processes, so ids stay unique on the process-backed path. Single fix point: new_id feeds request/environment/runtime/invocation/event ids. smoke_sdk_concurrency failed ~25% of runs before; 0/20 after. Signed-off-by: Ajay Thorve --- crates/fabric-core/src/runtime.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/fabric-core/src/runtime.rs b/crates/fabric-core/src/runtime.rs index eac109479..b18b2e0cb 100644 --- a/crates/fabric-core/src/runtime.rs +++ b/crates/fabric-core/src/runtime.rs @@ -1547,8 +1547,12 @@ fn event_with_metadata( } fn new_id(prefix: &str) -> String { + // The atomic counter only differentiates ids within a single process; a + // process-backed runner spawns a fresh `fabric-cli` per call, resetting it + // to 1. Include the process id (distinct across concurrently running + // processes) so ids stay unique when two runs land in the same millisecond. let counter = NEXT_ID.fetch_add(1, Ordering::Relaxed); - format!("{prefix}-{}-{counter}", now_millis()) + format!("{prefix}-{}-{}-{counter}", now_millis(), std::process::id()) } fn now_millis() -> u128 {