Tinkv example: is this a bug?

Am I missing something, or does this line look like a useless duplicate ?

The rest of the files explicitly checks the timing of TOTAL_KEYS * 2 writes.
So no, it's not useless.
Probably with the idea of timing the write of a non-existing key and then an existing key.

2 Likes
  1. I think you are spot on with it writing twice on purpose.

  2. For bitcask, I think there is no difference between writing to non-existing key vs writing of existing key (both writes go to the segment-log). The only difference ends up during the compact phase:

With just one write, there would be no garbage to collect, but writing it twice makes the first one 'garbage' to be collected (not copied).

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.