cinchapi / concourse

Distributed database warehouse for transactions, search and analytics across time.
http://concoursedb.com
Apache License 2.0
315 stars 234 forks source link

The Database can accept duplicate Writes if Blocks are partially synced #441

Closed jtnelson closed 3 years ago

jtnelson commented 3 years ago

It is possible for the Database to accept duplicate Writes upon restarting after a crash. Consider a scenario where there Buffer contains:

ADD Y
ADD X
REMOVE X
ADD X
REMOVE X

and both cpb and csb are written, but ctb is not, preventing the Buffer page from being deleted.

When the server restarts, an attempt will be made to reply ADD Y, but it will fail because the database (per the written cpb) will contain Y.

However, when an attempt is made to replay ADD X, it will succeed because the database (per the written cpb) will contain X. This is possible because the value of the Writes are checked instead of checking the version numbers. Since the replay succeeds, the remaining writes in the buffer will ALL be replayed and duplicated.

This does not lead to any data consistency issues per se, but the write versions will be duplicated.