From 12fd60f92ec1a46b4687afdfeecc1240ed6364a9 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 26 Aug 2026 08:58:34 -0700 Subject: [PATCH] rust volume: stop racing the clock in torn_sdx_is_regenerated (#10966) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test truncates a good .sdx and asserts the result still looks fresher than its .idx, on the reasoning that truncation bumps the mtime. That holds only at the filesystem's timestamp granularity: where both writes land in the same tick the precondition fails and the run reports a failure that says nothing about the code under test — as it did on CI. Backdate the .idx the way the sibling stale_sdx_is_regenerated already does. --- seaweed-volume/src/storage/needle_map/sorted_file.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/seaweed-volume/src/storage/needle_map/sorted_file.rs b/seaweed-volume/src/storage/needle_map/sorted_file.rs index 557124c4c..cdcde940a 100644 --- a/seaweed-volume/src/storage/needle_map/sorted_file.rs +++ b/seaweed-volume/src/storage/needle_map/sorted_file.rs @@ -807,6 +807,13 @@ mod tests { sdx.set_len(good - 5).unwrap(); drop(sdx); pooled_index_files().discard(&format!("{base}.sdx")); + // Truncation bumps the .sdx mtime, but "bumps" is only true at the + // filesystem's timestamp granularity: where both writes land in the + // same tick the torn file does not look fresher, and the precondition + // below then fails for a reason the test is not about. Age the .idx the + // way stale_sdx_is_regenerated does, so freshness is established rather + // than raced for. + filetime_backdate(&format!("{base}.idx")); assert!( std::fs::metadata(format!("{base}.sdx")) .unwrap()