From 7c8b5c5ef0193c7bdab8c3e6e811b91433d43ea8 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 9 Mar 2026 14:43:24 -0400 Subject: [PATCH] fix(cold): drain in-flight reads before executing writes The task runner's select loop executed writes immediately without waiting for spawned read tasks to complete, allowing reads and writes to race on the backend. Close and drain the TaskTracker before each write to ensure exclusive access, then reopen for subsequent reads. Closes ENG-1980 Co-Authored-By: Claude Opus 4.6 --- crates/cold/src/task/runner.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/cold/src/task/runner.rs b/crates/cold/src/task/runner.rs index b0a2114..43ff773 100644 --- a/crates/cold/src/task/runner.rs +++ b/crates/cold/src/task/runner.rs @@ -331,6 +331,12 @@ impl ColdStorageTask { debug!("Cold storage write channel closed"); break; }; + // Drain in-flight reads before executing the write to + // ensure exclusive access to the backend. + self.task_tracker.close(); + self.task_tracker.wait().await; + self.task_tracker.reopen(); + self.inner.handle_write(req).await; }