Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

rust volume: stop racing the clock in torn_sdx_is_regenerated (#10966)

Chris Lu12fd60f92ec1
diff --git a/seaweed-volume/src/storage/needle_map/sorted_file.rs b/seaweed-volume/src/storage/needle_map/sorted_file.rs
index 557124c4c7..cdcde940ac 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()