-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird bug in file metadata modified timestamp returned by OS #71
Conversation
I've reproduced the issue with an even smaller test. The os is returning different metadata for the same file. #[test]
fn test_file_timestamp_bug() {
let temp_dir =
TempDir::new("tmp").expect("Failed to create temporary directory");
let storage_path = temp_dir.path().join("teststorage.txt");
let mut file_storage =
FileStorage::new("TestStorage".to_string(), &storage_path).unwrap();
file_storage.set("key1".to_string(), "value1".to_string());
let updated = file_storage.write_fs().unwrap();
let file_updated = fs::metadata(&file_storage.path)
.unwrap()
.modified()
.unwrap();
assert_eq!(file_updated, updated);
}
|
Signed-off-by: Tarek <[email protected]>
The issue seems to be related to For reference, see the To resolve this, I've added a call to I've pushed a commit with this fix. |
That was a very tricky bug. Thanks for the fix. Reading the documentation I realize that BufWriter is not a good fit for our purpose since we want to write the whole mapping to disk at once.
I'll remove the BufWriter and use just a writer which will avoid such tricky bugs later. |
* Use millisecond resolution when comparing timestamps * Use nanos * Round down scan time * Use micros * Update syncing logic with some api changes * Abstract loading from fs logic * Add full syncing logic * Fix need syncing logic * Address comments * Fix lints * add a 1sec sleep Signed-off-by: pushkarm029 <[email protected]> * check Signed-off-by: pushkarm029 <[email protected]> * fmt Signed-off-by: pushkarm029 <[email protected]> * Update fs-storage/src/file_storage.rs Co-authored-by: Kirill Taran <[email protected]> * Update fs-storage/src/file_storage.rs Co-authored-by: Kirill Taran <[email protected]> * Update fs-storage/src/file_storage.rs Co-authored-by: Kirill Taran <[email protected]> * Add doc comments on FileStorage fields * Weird bug in file metadata modified timestamp returned by OS (#71) * File modified metadata bug * Add even smaller test * fix(fs-storage): flush the buffer in write_fs() Signed-off-by: Tarek <[email protected]> --------- Signed-off-by: Tarek <[email protected]> Co-authored-by: Tarek <[email protected]> * Use file writer and update test * cargo fix * Weird bug in file metadata again * Update fs-storage/src/file_storage.rs Co-authored-by: Tarek Elsayed <[email protected]> * Update fs-storage/src/base_storage.rs Co-authored-by: Tarek Elsayed <[email protected]> * Refactor sync_status to cleaner match case Co-authored-by: Tarek <[email protected]> * Add MRE for file metadata timestamp not updated on write_fs * fmt fix * fix(fs-storage): add delay in tests after file write Signed-off-by: Tarek <[email protected]> * Set file modified timestamp from application layer * Fmt fix * Update fs-storage/src/file_storage.rs Co-authored-by: Tarek Elsayed <[email protected]> * Resolve comments * Fix fmt --------- Signed-off-by: pushkarm029 <[email protected]> Signed-off-by: Tarek <[email protected]> Co-authored-by: pushkarm029 <[email protected]> Co-authored-by: Kirill Taran <[email protected]> Co-authored-by: Tarek <[email protected]> Co-authored-by: Tarek Elsayed <[email protected]>
The file metadata modified timestamp returns different values for reading the same file without any changes 🤯. Which is causing the bug in #63.
This is a separate PR to discuss and debug it. Here's output from the modified test that's failing for me locally. It has two different timestamps for the same file even though there is no modification between the two readings.
Can others reproduce this locally as well?