Open unixod opened 2 months ago
Hi @unixod
s
contains the information of the snapshot that the current NuRaft instance (leader) is transmitting to its follower. It can be the latest snapshot, or older than that.s
will remain unchanged unless a new snapshot transmission begins.In short,
create_snapshot
: s
contains the latest snapshot info, that the state machine has to create.read_logical_snp_obj
: s
contains the snapshot that the current leader is transmitting. s
will remain the same until the entire transmission session (consists of many read_logical_snp_obj
calls) either succeeds or fails. If it fails, read_logcial_snp_obj
will be retried with newer s
.save_logical_snp_obj
, apply_snapshot
: same as read_logical_snp_obj
.Hi @greensky00
Thanks, the answer clarified a lot of things. But I still have several questions.
read_logical_snp_obj
function. There is an if block there, and I am wondering what are the concrete cases that we can enter that block?0
in that block if that is considered to be failure of snapshot reading (I mean why don't we return a negative value)?snapshot
argument from? Am I correct that it gets it from calling last_snapshot
on the leader node?snapshot
argument is non const in all of the functions above, I suppose that user can modify it. Am I correct and if yes, what are those cases when the first argument can be modified?Hi @grigoryan-sergey
read_logical_snp_obj
when no snapshot exists. That code is to smoothly get over such a situation without corrupting the system. 0
. I will fix it; thanks for bringing it up.snapshot
instance. read_logical_snp_obj
just inherited the legacy read_snapshot_data
from Cornerstone, which is why it is non-const. But basically you should regard it as read-only.
Hi,
Is it correct to assume that for each call of
read_logical_snp_obj(s, ...)
made by NuRaft, the following holds?s
contains an information about raft log entry at which latest snapshot was made;s
is equal to the one which was passed to latest call ofcreate_snapshot
(i.e. s.get_last_log_idx() is equal to index of latest log entry included into latest snapshot);To be more general, I'm wondering what information is passed as a first parameter to functions:
create_snapshot(snapshot&, ...)
read_logical_snp_obj(snapshot&, ...)
save_logical_snp_obj(snapshot&, ...)
apply_snapshot(snapshot&, ...)