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

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.
This commit is contained in:
Chris Lu
2026-08-26 08:58:34 -07:00
committed by GitHub
parent da087f77b3
commit 12fd60f92e
@@ -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()