Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make raft leader resume probing after snapshot crash #2707

Merged
merged 6 commits into from
Oct 30, 2018

Conversation

manishrjain
Copy link
Contributor

@manishrjain manishrjain commented Oct 30, 2018

When a raft follower is considered to be falling behind, leader sends it a snapshot. The follower then opens a streaming connection to the leader, asking it to send the snapshot. If the follower crashes while receiving and applying the snapshot, it is left in a permanent limbo, receiving no more raft updates. This was because the leader pauses its probing until it hears back from the follower. This "persists" through follower crash and restart.

This PR makes the snapshot streaming bi-directional. So, the follower can send an ACK back to the leader when it has successfully applied the snapshot. If the leader gets an error instead, it would mark the snapshot as a failure, and resume probing.

The end effect is that, if the follower crashes while receiving a snapshot, leader resumes probing, so when the follower comes back up, it again requests a snapshot from the leader.

Fixes #2698 .

P.S. I wish etcd's raft lib had better documentation to warn us about this, via the function. I'll create another PR to improve their godocs.


This change is Reviewable

@manishrjain manishrjain requested a review from srfrog October 30, 2018 16:59
Copy link
Contributor

@srfrog srfrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6 of 6 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@manishrjain manishrjain merged commit 165817a into master Oct 30, 2018
@manishrjain manishrjain deleted the mrjn/reorder-snapshot branch October 30, 2018 20:07
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 19, 2019
When a raft follower is considered to be falling behind, leader sends it a snapshot. The follower then opens a streaming connection to the leader, asking it to send the snapshot. If the follower crashes while receiving and applying the snapshot, it is left in a permanent limbo, receiving no more raft updates. This was because the leader pauses its probing until it hears back from the follower. This "persists" through follower crash and restart.

This PR makes the snapshot streaming bi-directional. So, the follower can send an ACK back to the leader when it has successfully applied the snapshot. If the leader gets an error instead, it would mark the snapshot as a failure, and resume probing.

The end effect is that, if the follower crashes while receiving a snapshot, leader resumes probing, so when the follower comes back up, it again requests a snapshot from the leader.

Fixes dgraph-io#2698 .

P.S. I wish etcd's raft lib had better documentation to warn us about this, via the function. I'll create another PR to improve their godocs.

* Change the order in which Snapshot is retrieved and WAL is `SaveToStorage`. So, if a follower is unable to retrieve the snapshot, it won't store it in the WAL. This allows future probing to work correctly.
* Some exploration to determine a good way to send ack of writes back to the leader.
* Recovers correctly from a node crash during snapshot streaming.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants