feat(local): reliable file writes for LocalFileSystem#662
Closed
jgiannuzzi wants to merge 1 commit intoapache:mainfrom
Closed
feat(local): reliable file writes for LocalFileSystem#662jgiannuzzi wants to merge 1 commit intoapache:mainfrom
jgiannuzzi wants to merge 1 commit intoapache:mainfrom
Conversation
Add explicit close with error checking on Unix (libc::close) and Windows (CloseHandle), replacing silent drop. Add opt-in sync_on_close for stronger durability guarantees on network filesystems (e.g. NFS).
Author
|
Hi @crepererum, could you please take a look at this change? Thanks! |
Contributor
|
As far as I can see, this has the same issue as #643: syncing the file itself is NOT enough for durability. You have to sync the directories as well. |
Author
|
Superseded by #676 which implements only the explicit |
Author
|
Thanks @crepererum, I had only looked at issues and not pull requests and thus hadn't seen #643. I have extracted the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #661.
Rationale for this change
See issue.
What changes are included in this PR?
close_file()helper that callslibc::close()(Unix) /CloseHandle(Windows) directly and propagates errors, instead of relying onFile::drop(). Note that this usesunsafe, like in the platforms' respectivedrop()implementations.with_sync_on_close(bool)builder method onLocalFileSystemthat callsFile::sync_all()before closing, providing stronger durability guarantees for network filesystems.putandput_multipart(viaLocalUpload) code paths.libc(Unix) andwindows-sys(Windows) as optional dependencies behind thefsfeature for their respective platforms.sync_on_close(true). Note that this doesn't "do" anything and is just there to validate that the additional behaviour does not create issues.close_filedetectsEBADFwhen the file descriptor is closed behind Rust's back. This is just to validate thatclose_fileproperly returns the OS error.Are there any user-facing changes?
New public API: LocalFileSystem::with_sync_on_close(bool) -> Self. Default is false (no behaviour change for existing users).
Close errors are now detected and propagated as
Error::UnableToCopyDataToFile. Previously these were silently ignored. This is a correctness improvement but could surface errors that were previously hidden.