New follower can get all the logs?

54 views
Skip to first unread message

john pradeep

unread,
Dec 7, 2016, 1:56:44 PM12/7/16
to raft-dev
Hi,
I just started going through the raft source code to understand the implementation in depth, I noticed that when a node runs as a follower for the first time then it starts processing the rpc commands straight away. this means it will end up having the logs from the point it was started and not the complete logs from the beginning of the cluster?

I understand this is an efficient approach especially with snapshot  and log compaction in place, but just wanted to confirm if my understanding is correct.


Thanks,
John

Oren Eini (Ayende Rahien)

unread,
Dec 7, 2016, 2:38:19 PM12/7/16
to raft...@googlegroups.com
That is the point of InstallSnapshot, yes.
It setup the state of the follower so it is near enough to the others that they can start reasonably sending the log entries to it

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "raft-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raft-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Diego Ongaro

unread,
Dec 7, 2016, 7:49:29 PM12/7/16
to raft...@googlegroups.com
Hi John,

If I'm reading your email correctly, not quite. A follower cannot make progress with gaps in the log. The leader may try to send it an entry at index N, but if it does not have a log entry or snapshot at N-1, they'll have to back up first. I suggest learning about Raft's log replication mechanism from a video or paper before trying to infer concepts from a particular implementation; see https://raft.github.io/.

BTW, there are many implementations of Raft, and we don't know which code you're reading.

-Diego

john pradeep

unread,
Dec 7, 2016, 10:28:17 PM12/7/16
to raft-dev
Hi Diego,
I am reading the source code at https://github.com/hashicorp/raft

If the follower has no previous logs (last index is 0) and recieves a command from the leader with index N then as you mentioned the follower should get the nearest snapshot or logs from the leader. But I couldn't spot that logic in the implementation.


Thanks,
John

Diego Ongaro

unread,
Dec 8, 2016, 12:54:35 AM12/8/16
to raft...@googlegroups.com
It's there. You're likely better off reading the library-v2-stage-two branch, I'd like to think peer.go is cleaner there.



Thanks,
John

john pradeep

unread,
Dec 8, 2016, 1:29:11 AM12/8/16
to raft-dev
Cool, will have a look. Thanks Diego!


On Thursday, December 8, 2016 at 11:24:35 AM UTC+5:30, Diego Ongaro wrote:
It's there. You're likely better off reading the library-v2-stage-two branch, I'd like to think peer.go is cleaner there.
On Wed, Dec 7, 2016 at 7:28 PM, john pradeep <yehoh...@gmail.com> wrote:
Hi Diego,
I am reading the source code at https://github.com/hashicorp/raft

If the follower has no previous logs (last index is 0) and recieves a command from the leader with index N then as you mentioned the follower should get the nearest snapshot or logs from the leader. But I couldn't spot that logic in the implementation.


Thanks,
John

--
You received this message because you are subscribed to the Google Groups "raft-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raft-dev+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages