basho / bitcask

because you need another a key/value storage engine
1.28k stars 171 forks source link

Remove expired on get race #191

Closed engelsanchez closed 10 years ago

engelsanchez commented 10 years ago

While documenting the read code path, I came across a race when reads find an expired value. The code then unconditionally removes that entry. BUT, this is not an atomic operation. A new value could have been written between the time we found the expired entry and the time we delete it. This needs to be changed to a conditional delete that will only remove the entry if it's exactly the same one we found, or try again if it has changed since the first get.

This is the line in bitcask:get/3 that does it: bitcask.erl#L238

engelsanchez commented 10 years ago

Fixed in the 1.7 branch by basho/bitcask#192. A separate issue will track the merge of this and other fixes for the Riak 2.0.1 release to the develop branch.