guille / RaftCore

An implementation of the Raft algorithm using .NET Core
MIT License
68 stars 22 forks source link

Add persistent state support #4

Open guille opened 6 years ago

guille commented 6 years ago

Although the designed implementation can withstand network connectivity issues, it does not offer full support for more severe circumstances, such as application crashes or power outages.

The main solution of this problem is considered in the Raft algorithm paper, and consists of persisting some of the node’s state. This would require adding a protocol to both serialize part of the node’s state and reload this configuration after node crashes. In the developed implementation, all state is volatile.

aidapsibr commented 5 years ago

Hey, been looking to learn consensus for a bit and this seems really helpful, so thanks for the work.

Regarding persisting state, I'd love to chat with you about REstate, a persistent state machine library I write in C#. It should support everything you require already, but additionally I am adding a strongly typed implementation called NaturalStateMachine.

https://github.com/psibr/REstate/tree/master/NaturalSchematicExamples/ProvisoningSystem

aidapsibr commented 5 years ago

May not be a good fit on looking further, but please advise. REstate is a DFA library by design, you IStateMachine seems to be a state reducer.

guille commented 5 years ago

Hi @psibernetic After taking a quick look, it doesn't seem to be a great fit as you say. The intent of IStateMachine is to take commands from the replicated log and execute them in order, ensuring that a list of the same commands executed in the same order results in the same state.

For example, with IStateMachine, a PostgreSQL database could be modelled by sending SQL commands. I don't think REstate offers those posibilities. Thanks for the interest anyway!