-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
release-22.2: storage: introduce test-build assertion iterator #97572
Conversation
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
bfb5442
to
05f7c76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this, pointSynthesizingIter
changes LGTM. Mind running a quick MVCCGet
benchmark to see the impact?
Reviewed 19 of 19 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @jbowens and @RaduBerinde)
pkg/storage/sst.go
line 615 at r1 (raw file):
// Re-retrieve the buffers. if extHasRange { extRangeKeys = extIter.RangeKeys()
Consider pulling this out to a separate commit for visibility.
pkg/storage/pebbleiter/crdb_test_off.go
line 19 at r1 (raw file):
// Iterator redefines *pebble.Iterator. type Iterator = *pebble.Iterator
Nice trick to avoid dynamic dispatch here.
Backport cockroachdb#90859, cockroachdb#96685 and cockroachdb#97222 to mangle the buffers returned by Pebble iterators to ensure MVCC and Cockroach code respects the Pebble iterator memory lifetimes. The RangeBounds() and RangeKeys() validity assertions are omitted, since 22.2 allowed these methods to be invoked on an invalid iterator or an iterator positioned at a point key. Release note: None Release justification: Non-production code changes
Fix a bug whereby CheckSSTConflicts could seek the engine iterator and seek back, assuming that the originally returned buffers were still valid. This is only true if RangeKeyChanged()=false after both seeks. Backport of part of cockroachdb#97222. Epic: None Release note: None
Previously, the spanset.MVCCIterator implementation would retrieve the contained iterator's UsafeKey() on an invalid iterator in Next, NextKey and Prev. This retrieval was harmless because it always checked the validity of the iterator before using it, but recent assertions in test builds prevent this usage. Release note: None
Update the point-synthesizing iterator to save range key state even when in prefix iteration mode. Previously the point-synthesizing iterator avoided copying the range key state when used within prefix iteration mode. This led to a bug where an iterator could be moved into an exhausted position, at which the previous range key buffers are no longer valid. Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
Mind running a quick MVCCGet benchmark to see the impact?
For sure. running them on my gceworker now
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @erikgrinaker and @RaduBerinde)
pkg/storage/sst.go
line 615 at r1 (raw file):
Previously, erikgrinaker (Erik Grinaker) wrote…
Consider pulling this out to a separate commit for visibility.
Good call, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impact looks not horrible:
name old time/op new time/op delta
MVCCGet_Pebble/batch=false/versions=1/valueSize=8/numRangeKeys=0-24 6.29µs ± 1% 6.32µs ± 1% ~ (p=0.310 n=5+5)
MVCCGet_Pebble/batch=false/versions=1/valueSize=8/numRangeKeys=1-24 11.5µs ± 1% 11.7µs ± 1% ~ (p=0.056 n=5+5)
MVCCGet_Pebble/batch=false/versions=1/valueSize=8/numRangeKeys=100-24 133µs ± 1% 129µs ± 1% -3.01% (p=0.008 n=5+5)
MVCCGet_Pebble/batch=false/versions=10/valueSize=8/numRangeKeys=0-24 25.8µs ± 0% 25.7µs ± 1% ~ (p=0.421 n=5+5)
MVCCGet_Pebble/batch=false/versions=10/valueSize=8/numRangeKeys=1-24 33.5µs ± 2% 34.0µs ± 2% +1.38% (p=0.032 n=5+5)
MVCCGet_Pebble/batch=false/versions=10/valueSize=8/numRangeKeys=100-24 115µs ± 1% 115µs ± 1% ~ (p=0.690 n=5+5)
MVCCGet_Pebble/batch=false/versions=100/valueSize=8/numRangeKeys=0-24 107µs ± 2% 107µs ± 1% ~ (p=0.421 n=5+5)
MVCCGet_Pebble/batch=false/versions=100/valueSize=8/numRangeKeys=1-24 117µs ± 1% 118µs ± 1% ~ (p=0.222 n=5+5)
MVCCGet_Pebble/batch=false/versions=100/valueSize=8/numRangeKeys=100-24 209µs ± 4% 208µs ± 1% ~ (p=1.000 n=5+5)
MVCCGet_Pebble/batch=true/versions=1/valueSize=8/numRangeKeys=0-24 3.82µs ± 1% 3.81µs ± 1% ~ (p=0.571 n=5+5)
MVCCGet_Pebble/batch=true/versions=1/valueSize=8/numRangeKeys=1-24 6.19µs ± 1% 6.14µs ± 1% ~ (p=0.310 n=5+5)
MVCCGet_Pebble/batch=true/versions=1/valueSize=8/numRangeKeys=100-24 69.2µs ± 0% 69.6µs ± 1% +0.70% (p=0.032 n=5+5)
MVCCGet_Pebble/batch=true/versions=10/valueSize=8/numRangeKeys=0-24 22.1µs ± 1% 22.0µs ± 2% ~ (p=0.310 n=5+5)
MVCCGet_Pebble/batch=true/versions=10/valueSize=8/numRangeKeys=1-24 27.6µs ± 1% 27.8µs ± 1% ~ (p=0.222 n=5+5)
MVCCGet_Pebble/batch=true/versions=10/valueSize=8/numRangeKeys=100-24 94.2µs ± 1% 95.7µs ± 1% +1.57% (p=0.032 n=5+5)
MVCCGet_Pebble/batch=true/versions=100/valueSize=8/numRangeKeys=0-24 105µs ± 1% 105µs ± 1% ~ (p=0.841 n=5+5)
MVCCGet_Pebble/batch=true/versions=100/valueSize=8/numRangeKeys=1-24 114µs ± 1% 114µs ± 2% ~ (p=0.841 n=5+5)
MVCCGet_Pebble/batch=true/versions=100/valueSize=8/numRangeKeys=100-24 188µs ± 3% 190µs ± 1% ~ (p=0.310 n=5+5)
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @erikgrinaker and @RaduBerinde)
TFTR! |
Backport #90859, #96685 and #97222 to mangle the buffers returned by Pebble
iterators to ensure MVCC and Cockroach code respects the Pebble iterator memory
lifetimes.
The RangeBounds() and RangeKeys() validity assertions are omitted, since 22.2
allowed these methods to be invoked on an invalid iterator or an iterator
positioned at a point key.
Epic: None
Release note: None
Release justification: Non-production code changes and fix to high-severity MVCC iterator bug.