-
Notifications
You must be signed in to change notification settings - Fork 8
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
Make KVTree file writes failure resistant #40
Comments
We'll also need to consider what to do about |
For |
So that I don't forget, here are some other things that come to mind when we get around to this. There are at least two types of write calls we'll want to change to write to a temp file and then rename instead of writing directly to the real file. The first is Line 1166 in 5121937
The second kind of write is Line 1526 in 5121937
For this second case, we may need both the open and close functions to deal with the temp name. Also, we'll need to figure out how to do the locking correctly. The locking is needed because there are two different processes trying to read/write the same file, and the locking is needed to serialize access. I don't know off hand if we need to lock the source file name, the new temp file name, or both. Finally, we need to consider how to delete a kvtree file. Currently, users of kvtree may delete the kvtree file directly when they cleanup. However, we'll now need to delete both the file and its temp name in case a process died before it could rename the temp file. For that, we'll either want add a parameter to the interface so that the user of kvtree can provide the name of the temp file, so they know what to delete, or we'll need to define a |
If there's a crash during
kvtree_file_write()
, it could result in a corrupted kvtree file (ECP-VeloC/AXL#83). @adammoody suggested that eachkvtree_file_write()
create a new file that getsrename()'d
to the final filename. Arename()
is atomic on Linux. This means that if there's a failure during the write, thenkvtree_read_file()
is going to return the kvtree state before the failed write rather than an error. We also may want to consider writing to the new kvtree file with O_DIRECT or O_ATOMIC for even more protection.The text was updated successfully, but these errors were encountered: