RaftCore icon indicating copy to clipboard operation
RaftCore copied to clipboard

Thread Safety

Open xucito opened this issue 5 years ago • 1 comments

Don't know if you are still working on this, but I looked at your implementation and found some issues - just a FYI.

A lot of the operations in your implementation are not thread safe.

An example of this is, your heartbeats interval can exceed the time it takes to complete a heartbeat, as a result you can have two "AppendEntries" running concurrently, this causes issues particularly when both threads reach

toApply.ForEach(x => StateMachine.Apply(x.Command));

applying your logs twice.

You should have dedicated threads that loop this check and log application.

xucito avatar Jun 02 '19 14:06 xucito

Yep, it's definitely an issue. I don't really have the time to keep improving RaftCore but if anyone wants to take a stab at it I'll review and merge the PR.

Thanks!

guille avatar Jun 04 '19 15:06 guille