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

Debug tool to modify Raft snapshot and hardstate #3364

Merged
merged 5 commits into from
May 3, 2019

Conversation

manishrjain
Copy link
Contributor

@manishrjain manishrjain commented May 3, 2019

This PR adds a way for the debug tool to operate upon the Raft logs to set a future snapshot and hardstate. This can be used to fix up a broken follower, who has fallen way behind the leader.


This change is Reviewable

@manishrjain manishrjain requested a review from a team as a code owner May 3, 2019 06:23
Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1.
Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions (waiting on @danielmai, @manishrjain, and @martinmr)


dgraph/cmd/debug/run.go, line 96 at r1 (raw file):

		"Remove data from Raft entries until but not including this index.")
	flag.StringVarP(&opt.wsetSnapshot, "snap", "s", "",
		"Set snapshot term,index,readts to this.")

"Set the snapshot term, index, and readTs. Value must be a comma-separated list containing the value for these variables in that order."


dgraph/cmd/debug/run.go, line 891 at r1 (raw file):

			store := raftwal.Init(db, rid, gid)
			switch {
			case len(opt.wsetSnapshot) > 0:

The logic to set the snapshot is quite long. Unless there's a good reason for it, I think this code should go into its own function, just like printRaft.


dgraph/cmd/debug/run.go, line 954 at r1 (raw file):

				x.Check(err)
				err = store.CreateSnapshot(dsnap.Index, &cs, data)
				fmt.Printf("Created snapshot with error: %v\n", err)

only print this if there's an error.

Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @danielmai and @manishrjain)

Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

:lgtm:

Just a couple comments but overall it looks good.

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @danielmai and @manishrjain)

Copy link
Contributor Author

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @danielmai and @martinmr)


dgraph/cmd/debug/run.go, line 96 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…

"Set the snapshot term, index, and readTs. Value must be a comma-separated list containing the value for these variables in that order."

Done.


dgraph/cmd/debug/run.go, line 891 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…

The logic to set the snapshot is quite long. Unless there's a good reason for it, I think this code should go into its own function, just like printRaft.

Done. Moved all the logic out of this file into a new wal.go file, so all raft stuff is separate. Also, moved the nested funcs outside.


dgraph/cmd/debug/run.go, line 954 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…

only print this if there's an error.

Done.

@manishrjain manishrjain merged commit 796d2a6 into master May 3, 2019
@manishrjain manishrjain deleted the mrjn/debug-raft-snapshot branch May 3, 2019 20:46
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 19, 2019
This PR adds a way for the debug tool to operate upon the Raft logs to set a future snapshot and hardstate. This can be used to fix up a broken follower, who has fallen way behind the leader.
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.

3 participants