RaftCore
RaftCore copied to clipboard
Thread Safety
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.
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!