Skip to content
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

Atomic file write: does not sync #27

Closed
joonas-fi opened this issue Sep 17, 2024 · 1 comment
Closed

Atomic file write: does not sync #27

joonas-fi opened this issue Sep 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@joonas-fi
Copy link
Member

joonas-fi commented Sep 17, 2024

It does Close() and Rename(), but NOT Sync() before close. Apparently Close() does not guarantee buffers hit the disk:

A successful close does not guarantee that the data has been successfully saved to disk, as the kernel defers writes. It is not common for a file system to flush the buffers when the stream is closed. If you need to be sure that the data is physically stored use fsync(2).

Source: close() syscall documentation

The (2) is a user-hostile way to abbreviate "(system call)"

@joonas-fi joonas-fi added the bug Something isn't working label Sep 17, 2024
@joonas-fi
Copy link
Member Author

Tailscale also uses .Sync() in their mini-library: tailscale/tailscale@bcbd411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant