You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
Currently it's possible for downstream readers to read a partially written file because WriteFile is not atomic. Ideally an updated file would only change once, and the change would be total, so that you'd either read the old state or the new state, but nothing in between.
One way to implement this is by writing to a temporary file and then renaming the file:
…me the file.
This helps to make sure that processes are watching the file never see a 0-length
file in the middle of an update.
This is being done because ioutil.Writefile truncates any existing file in place
which at high velocities means bad things can happen.
This makes sure that the file is replaced atomically.
This also means we can remove the chmod code we added here:
#78
Since we're always creating a new file - the perms will always be correct.
Original bug: #88
Currently it's possible for downstream readers to read a partially written file because
WriteFile
is not atomic. Ideally an updated file would only change once, and the change would be total, so that you'd either read the old state or the new state, but nothing in between.One way to implement this is by writing to a temporary file and then renaming the file:
This works because renaming a file in unix is atomic.
One thing to keep in mind that is that it's only atomic on the same physical device. So writing to
/tmp
may not work.The text was updated successfully, but these errors were encountered: