compaction process in copycat

41 views
Skip to first unread message

Terry Tan

unread,
Dec 23, 2016, 1:25:43 AM12/23/16
to raft-dev
Hi Jordan,
 
I found that when we decided to release an entry ,it will be noted to memo like a bitmap, then during the compaction process ,the entries being released will be removed ,but what if the server crashed before the compaction process , will the lost entries never get a chance to be removed ,if it is not,when it will be released?

jordan.h...@gmail.com

unread,
Dec 29, 2016, 6:17:16 AM12/29/16
to raft...@googlegroups.com
Sorry, I've been in and out during the holidays, but thanks for the question!

So, you're right that when an entry is released by the state machine in Copycat it simply sets a bit in an in-memory bitmap and uses that map for compaction. So, the usage of the bitmap really relies upon the mechanisms of the Raft algorithm. Right now, Copycat only supports in memory state machines, meaning entries are replayed when a server crashes and restarts to rebuild the system's state. Assuming state machines are deterministic, this means entries will be replayed, and entries that no longer contribute to the state machine will simply be released again, thus rebuilding the compaction bitmap as the state machine's state is rebuilt. Nothing about the compaction process is ever stored on disk. It relies entirely on the replay of commands to a deterministic state machine to recover state as is done in the state machine itself.

Obviously, this could cause problems if compaction is not done correctly, particularly as it relates to tombstones. If e.g. in the proverbial map state machine, a remove command is applied which deletes the state of a key, if that remove command is removed from disk before all prior entries for that key, that could result in the key effectively re-appearing when the server crashes and restarts. Copycat accounts for this by only periodically compacting tombstones from the log using a full sequential scan and rewrite of the log to ensure the tombstone and all prior released entries are removed at the same time. This process is described in further detail in the Log Compaction section of the documentation on the website:


On Dec 22, 2016, at 10:25 PM, Terry Tan <tx...@sina.com> wrote:

Hi Jordan,
 
I found that when we decided to release an entry ,it will be noted to memo like a bitmap, then during the compaction process ,the entries being released will be removed ,but what if the server crashed before the compaction process , will the lost entries never get a chance to be removed ,if it is not,when it will be released?

--
You received this message because you are subscribed to the Google Groups "raft-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raft-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Terry Tan

unread,
Dec 29, 2016, 10:24:14 PM12/29/16
to raft-dev
Hi Jordan,

Thank you for your reply.

happy new year .


在 2016年12月23日星期五 UTC+8下午2:25:43,Terry Tan写道:
Reply all
Reply to author
Forward
0 new messages