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

storage: invalidate cached lastTerm on snapshots #18327

Merged

Conversation

nvanbenschoten
Copy link
Member

Addresses the current issue in #17524.

I'll open an issue to properly test this, but that might take some time.
Fow now this seems like a clear fix that we should get in sooner rather
than later.

@nvanbenschoten nvanbenschoten requested review from petermattis and a team September 7, 2017 16:17
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Looks good, but it strikes me as brittle that we have two values that are tied together but are kept separate.

Maybe a struct lastTermAndIndex could make it more obvious that changing one without the other is illegal. Just a thought though.

// raftpb.SnapshotMetadata.
r.mu.lastIndex = s.RaftAppliedIndex
r.mu.lastTerm = 0
r.mu.lastIndex, r.mu.lastTerm = lastIndexAndTermInSnapshot(inSnap)
Copy link
Member

Choose a reason for hiding this comment

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

couldn't you just return struct lastIndexAndTerm from applySnapshot and save the other call to lastIndexAndTermInSnapshot? Nit, but I think it might be clearer.

@petermattis
Copy link
Collaborator

:lgtm: modulo not changing where we retrieve lastIndex from following a snapshot.


Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions, some commit checks pending.


pkg/storage/replica.go, line 3254 at r1 (raw file):

		if lastIndex, err = r.raftMu.stateLoader.loadLastIndex(ctx, r.store.Engine()); err != nil {
			return stats, err
		}

For a 1.1 cherry-pick, I'd prefer doing lastTerm = invalidLastTerm and stick with loading lastIndex from disk.


Comments from Reviewable

@nvanbenschoten
Copy link
Member Author

Heh, two opposite recommendations. Should I split it up into two commits, one with just the one line change and one with the rest? Then we can just cherry-pick in the first one.

@tbg
Copy link
Member

tbg commented Sep 7, 2017 via email

@petermattis
Copy link
Collaborator

I don't feel strongly, we could also just do the beauty refactor later in
the cycle if we track it. Getting a nice contained cherry-pick is the more
important item.

Agreed on the nicely contained cherry-pick being the priority. That's what @nvanbenschoten and i discussed in person. I think it should be followed up quickly with both the beauty refactor and a test.

Addresses the current issue in cockroachdb#17524.

I'll open an issue to properly test this, but that might take some time.
Fow now this seems like a clear fix that we should get in sooner rather
than later.
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/lastTerm branch from 17ff1da to e39e856 Compare September 7, 2017 18:56
@nvanbenschoten
Copy link
Member Author

Done. PTAL.

Opened #18336 to track cleanup and testing.

@petermattis
Copy link
Collaborator

:lgtm:


Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions, some commit checks pending.


Comments from Reviewable

@nvanbenschoten nvanbenschoten merged commit 839cf5e into cockroachdb:master Sep 7, 2017
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/lastTerm branch September 7, 2017 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants