Browse files

Fix old/reintroduced race condition with merge

An earlier version of this if statement in bitcask_nifs_keydir_put_int()
included this timestamp check ... and it's certainly necessary, to avoid
a race with a merge where the merge candidate has a timestamp that's
older than the current keydir entry.
  • Loading branch information...
1 parent 7508d88 commit 5c310d02bc6ee5e5b6046dac7eb03401649575d3 @slfritchie slfritchie committed Nov 12, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 c_src/bitcask_nifs.c
View
2 c_src/bitcask_nifs.c
@@ -639,6 +639,8 @@ ERL_NIF_TERM bitcask_nifs_keydir_put_int(ErlNifEnv* env, int argc, const ERL_NIF
if ((entry.newest_put &&
(entry.file_id >= keydir->biggest_file_id)) ||
(! entry.newest_put &&
+ (old_entry->tstamp < entry.tstamp)) ||
+ (! entry.newest_put &&
((old_entry->file_id < entry.file_id) ||
(((old_entry->file_id == entry.file_id) &&
(old_entry->offset < entry.offset))))))

0 comments on commit 5c310d0

Please sign in to comment.