Fix O_SYNC flag when opening data files#272
Conversation
|
@nsaadouni - don't know if you've picked up on this PR, but is this something your team could look at? |
|
Note that this is also I believe broken when using the I think this is an issue dating back to when a bespoke version of the erlang VM was used within Riak that was patched to add support for For a new user of bitcask, I think use of the Would be interesting to know what the current big users of bitcask actually use in production. |
|
@martinsumner In our case, the main reason we chose the
So we just relied on the |
According to Riak's docs, using the POSIX C API to write files, together with the
o_syncstrategy, should result in synchronous data writes. However, when looking at the open file descriptors for the Bitcask data, we can see that only the.write.lockfiles are opened with theO_SYNCflag, e.g.:This means writes are still asynchronous, which could lead to data loss even after sending the reply to the client.
The reason for this is that while the
get_file_open_flagsC function adds theO_SYNCto the bitmask, it replaces it when it receives anATOM_CREATEoption. The easiest fix is to simply add theo_syncoption to the end of the list atbitcask_fileops.erl:87, to ensure that it always appears after thecreate. Now the files are correctly opened with theO_SYNCflag: