mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-28 11:56:07 +00:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user