-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
raftexample: Fix recovery from snapshot #11889
Conversation
612f7ad
to
ae8e73d
Compare
@gyuho Could you kindly review this? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions. |
Found the same problem, bro. When I was developing my graduation project last year, I referenced this sample and I found there seemed to be something wrong here. At that time I'm a beginner in etcd or raft, and I thought that I have missed something. When I am reviewing the sample and writing my blog, I found there IS a bug. It is very misleading for a beginner. |
ae8e73d
to
2b57b2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me, but I've never looked at |
Unfortunately same as Ben here, I have never actually interacted with this
raftexample code.
…On Tue, Feb 2, 2021 at 7:22 AM Shintaro Murakami ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In contrib/raftexample/raft.go
<#11889 (comment)>:
> @@ -428,6 +415,7 @@ func (rc *raftNode) serveChannels() {
// store raft entries to wal, then publish over commit channel
case rd := <-rc.node.Ready():
+ rc.maybeTriggerSnapshot()
We have to trigger snapshot before publishEntries because writing
in-memory map is async via commitC. If not do so, when taking snapshot,
entries may not be applied to the map yet.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11889 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGXPZDXZYYLUDIN6NSF2WLS46K2ZANCNFSM4NANVANQ>
.
|
* If there is a snapshot, HTTP server won't start. * Resotring form snapshot occurs after replaying WAL. * When taking a snapshot, the last change is not applied to the state machine yet.
b1f1dd4
to
836f8cf
Compare
@@ -353,6 +340,13 @@ func (rc *raftNode) maybeTriggerSnapshot() { | |||
return | |||
} | |||
|
|||
// wait until all committed entries are applied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add:
// commitC is synchronous channel, so consumption of the message signals
// full application of previous messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
To take a snapshot
836f8cf
to
be2167e
Compare
This function doesn't return.
etcd/contrib/raftexample/kvstore.go
Line 43 in 7cc2f8a