Skip to content

storage: Don't advance keys in MVCCGet with Pebble#48239

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
itsbilal:advancekey-fix
Apr 30, 2020
Merged

storage: Don't advance keys in MVCCGet with Pebble#48239
craig[bot] merged 1 commit intocockroachdb:masterfrom
itsbilal:advancekey-fix

Conversation

@itsbilal
Copy link
Copy Markdown
Contributor

Previously, when doing an MVCCGet with the Pebble MVCC scanner,
we would advance keys after getting (or not getting) the value
we're looking for. In some cases this could result in a seek,
such as if there are too many revisions of that MVCC key. Seeks
are costly and at best avoided when it's ultimatey unnecessary.

Another side effect of doing this seek was that it would trip
an assertion in spanSet.Iterator that checked if all reads
were happening on allowed key spans. This caused TestDumpData
to fail on Pebble (but not on RocksDB since the RocksDB MVCC
scanner is specialized in C++ and doesn't flow through the same
assertion for seeks).

There's one additional change, stemming from a follow-up conversation
in #48160, around unifying logic for terminating an MVCC scan.
The getFromIntentHistory() case also calls into addAndAdvance()
now.

Fixes #48147.

Release note: None.

@itsbilal itsbilal requested review from jbowens, petermattis and tbg April 30, 2020 17:27
@itsbilal itsbilal self-assigned this Apr 30, 2020
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@petermattis petermattis 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 modulo a few small comments.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @itsbilal, @jbowens, @petermattis, and @tbg)


pkg/storage/mvcc.go, line 794 at r1 (raw file):

	mvccScanner.init(opts.Txn)
	mvccScanner.get()

Perhaps we should set isGet = true in .get() and isGet = false in .scan().


pkg/storage/pebble_mvcc_scanner.go, line 220 at r1 (raw file):

// unmarshalled already. Returns true if a value was read and added to the
// result set.
func (p *pebbleMVCCScanner) getFromIntentHistory() (found bool, value []byte) {

It would be slight more idiomatic for this to be value []byte, found bool. That would match up with the multi-value version of map lookup and with type assertions where the second parameter is the boolean.


pkg/storage/pebble_mvcc_scanner.go, line 244 at r1 (raw file):

		return false, nil
	}
	intent := p.meta.IntentHistory[upIdx-1]

This should probably be intent := &p.meta.IntentHistory[upIdx-1].

Previously, when doing an MVCCGet with the Pebble MVCC scanner,
we would advance keys after getting (or not getting) the value
we're looking for. In some cases this could result in a seek,
such as if there are too many revisions of that MVCC key. Seeks
are costly and at best avoided when it's ultimatey unnecessary.

Another side effect of doing this seek was that it would trip
an assertion in spanSet.Iterator that checked if all reads
were happening on allowed key spans. This caused TestDumpData
to fail on Pebble (but not on RocksDB since the RocksDB MVCC
scanner is specialized in C++ and doesn't flow through the same
assertion for seeks).

There's one additional change, stemming from a follow-up conversation
in cockroachdb#48160, around unifying logic for terminating an MVCC scan.
The getFromIntentHistory() case also calls into addAndAdvance()
now.

Fixes cockroachdb#48147.

Release note: None.
Copy link
Copy Markdown
Contributor Author

@itsbilal itsbilal left a comment

Choose a reason for hiding this comment

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

TFTR!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jbowens, @petermattis, and @tbg)


pkg/storage/mvcc.go, line 794 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Perhaps we should set isGet = true in .get() and isGet = false in .scan().

Done.


pkg/storage/pebble_mvcc_scanner.go, line 220 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

It would be slight more idiomatic for this to be value []byte, found bool. That would match up with the multi-value version of map lookup and with type assertions where the second parameter is the boolean.

Done.


pkg/storage/pebble_mvcc_scanner.go, line 244 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

This should probably be intent := &p.meta.IntentHistory[upIdx-1].

Done.

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jbowens and @tbg)

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Apr 30, 2020

❌ The GitHub CI (Cockroach) build has failed on d0da8ef8.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@itsbilal
Copy link
Copy Markdown
Contributor Author

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 30, 2020

Build failed (retrying...)

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 30, 2020

Build succeeded

@craig craig bot merged commit b8f4815 into cockroachdb:master Apr 30, 2020
@itsbilal itsbilal deleted the advancekey-fix branch May 1, 2020 15:41
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.

cli: TestDumpData fails with KV error

3 participants