Closed yossigo closed 6 years ago
That makes a lot of sense. For example, you could isolate a key value store FSM when it's being snapshotted by iterating over the keys and being aware of log entries setting values.
However, I like that the default behaviour is so strict. It makes it easier to not break things. Therefore I think a good way to allow this is by adding flags to raft_begin_snapshot
. This is what I'm thinking about doing:
#define RAFT_SNAPSHOT_NONBLOCKING_APPLY 1
int raft_begin_snapshot(raft_server_t *me_, int flags);
Good optimisation for FSMs that can use this
Currently
raft_apply_entry()
andraft_apply_all()
will avoid applying entries if a snapshot is in progress. Assuming the FSM is able to provide the proper isolation, I don't see any real reason to prevent this in the library but @willemt perhaps you do?This requires care in maintaining the different indexes, but we anyway must assume the commit index can advance during snapshots (see #84 for example).