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

Update RAFT checkpoint when doing a clean shutdown. #5097

Merged
merged 4 commits into from Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions dgraph/cmd/alpha/run.go
Expand Up @@ -504,6 +504,13 @@ func setupServer(closer *y.Closer) {
if err := httpListener.Close(); err != nil {
glog.Warningf("Error while closing HTTP listener: %s", err)
}

// Update checkpoint so that proposals are not replayed after the server restarts.
if err := worker.UpdateRaftProgress(); err != nil {
glog.Warningf("Error while updating RAFT progress before shutdown: %s", err)
} else {
glog.Infof("Successfully updated RAFT state before shutting down")
}
}()

glog.Infoln("gRPC server started. Listening on port", grpcPort())
Expand Down
8 changes: 8 additions & 0 deletions worker/draft.go
Expand Up @@ -851,6 +851,14 @@ func (n *node) updateRaftProgress() error {
return nil
}

func UpdateRaftProgress() error {
gr := groups()
if gr == nil || gr.Node == nil {
return nil
}
return gr.Node.updateRaftProgress()
}

func (n *node) checkpointAndClose(done chan struct{}) {
slowTicker := time.NewTicker(time.Minute)
defer slowTicker.Stop()
Expand Down