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: Enforce that all keys accessed are declared in SpanSet #13864

Merged
merged 3 commits into from
Mar 16, 2017

Conversation

bdarnell
Copy link
Contributor

@bdarnell bdarnell commented Mar 1, 2017

Adds DeclareKeys implementations for all commands. Does not yet cover
keys whose use is implied by use of in-memory fields of the replica
state.

This is an updated and cleaned-up version of #10084.


This change is Reviewable

@petermattis
Copy link
Collaborator

:lgtm:


Reviewed 6 of 6 files at r1, 5 of 5 files at r2.
Review status: 8 of 13 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


pkg/storage/span_set.go, line 99 at r2 (raw file):

type spanSetIterator struct {
	i     engine.Iterator

I think if you embedded engine.Iterator, I think you can avoid some of the method exporting you did in the previous commit. I don't feel particularly strongly about this, though.


Comments from Reviewable

@bdarnell
Copy link
Contributor Author

bdarnell commented Mar 6, 2017

Review status: 8 of 13 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


pkg/storage/span_set.go, line 99 at r2 (raw file):

Previously, petermattis (Peter Mattis) wrote…

I think if you embedded engine.Iterator, I think you can avoid some of the method exporting you did in the previous commit. I don't feel particularly strongly about this, though.

I think only the visible methods of an embedded field get promoted to the new struct. More importantly, if this were embedded, the compiler would no longer warn us if we added a new method to the interface without implementing it here.


Comments from Reviewable

@petermattis
Copy link
Collaborator

Review status: 8 of 13 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


pkg/storage/span_set.go, line 99 at r2 (raw file):

Previously, bdarnell (Ben Darnell) wrote…

I think only the visible methods of an embedded field get promoted to the new struct. More importantly, if this were embedded, the compiler would no longer warn us if we added a new method to the interface without implementing it here.

I'm pretty sure all of the methods, not just the exported ones, get promoted to the new struct. We used this in sql-land at some point. I think we also used this in rangeDataIterator in some incarnation. Regardless, the current approach is fine.


Comments from Reviewable

@bdarnell
Copy link
Contributor Author

Added some tests and fixed some bugs (a couple in the new spanSetIterator code, and one in the unused roachpb.Span.Contains). Will squash the last commit before merging.

@petermattis
Copy link
Collaborator

:lgtm:


Reviewed 5 of 5 files at r3, 2 of 2 files at r4.
Review status: 13 of 15 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


pkg/storage/span_set.go, line 111 at r4 (raw file):

func (s spanSetIterator) Seek(key engine.MVCCKey) {
	if s.err == nil {

What's this about? The previous code was only overwriting s.err if it was nil. Was that problematic?


pkg/storage/span_set_test.go, line 66 at r5 (raw file):

	ss.Add(SpanReadOnly, roachpb.Span{Key: roachpb.Key("g")})
	ss.Add(SpanReadOnly, roachpb.Span{Key: roachpb.Key("k"), EndKey: roachpb.Key("q")})
	t.Logf("%s", ss.spans)

Remove?


Comments from Reviewable

@bdarnell
Copy link
Contributor Author

Review status: 13 of 15 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


pkg/storage/span_set.go, line 111 at r4 (raw file):

Previously, petermattis (Peter Mattis) wrote…

What's this about? The previous code was only overwriting s.err if it was nil. Was that problematic?

In the first version of this change, an invalidated iterator stays invalid forever. With this line removed, an iterator can be reused by seeking back in bounds. I don't know how much we care about that but it seemed like the right thing to do.


pkg/storage/span_set_test.go, line 66 at r5 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Remove?

Done.


Comments from Reviewable

@bdarnell bdarnell force-pushed the span-set-engine branch 4 times, most recently from 7870682 to 7266397 Compare March 16, 2017 19:15
@bdarnell
Copy link
Contributor Author

I forgot to test the previous round of this PR with propEvalKV enabled (which is the only time it does anything interesting), so I had to make some more updates. Unfortunately even though I uploaded all my intermediate commits before rebasing and squashing, reviewable seems to have eaten them so it's not easy to review just what changed in this round. Fortunately there's nothing too interesting in the new parts. There's a change to SpanSetIterator semantics (stepping out of bounds sets Valid() to false, but isn't an error), additions of new keys to various declareKeys methods, and a bit of a hack to unwrap the SpanSetIterator in storageccl.WriteBatch.


Review status: 4 of 16 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable

In a future commit, evaluation will go through these wrappers to
ensure that we are adding all necessary keys to the command queue.
Adds DeclareKeys implementations for all commands. Does not yet cover
keys whose use is implied by use of in-memory fields of the replica
state.

This is an update and cleaned-up version of cockroachdb#10084.
@bdarnell bdarnell merged commit 833b6f3 into cockroachdb:master Mar 16, 2017
@bdarnell bdarnell deleted the span-set-engine branch March 16, 2017 22:23
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.

2 participants