db: only switch to combined iteration on RangeKeySet keys#1856
Merged
jbowens merged 1 commit intocockroachdb:masterfrom Aug 5, 2022
Merged
db: only switch to combined iteration on RangeKeySet keys#1856jbowens merged 1 commit intocockroachdb:masterfrom
jbowens merged 1 commit intocockroachdb:masterfrom
Conversation
Member
jbowens
commented
Aug 5, 2022
Contributor
Author
jbowens
left a comment
There was a problem hiding this comment.
Race metamorphic tests revealed a problem. We need to hold D.mu to read table stats. I think this shouldn't be too hard to relax.
Reviewable status: 0 of 13 files reviewed, all discussions resolved
Previously, the lazy combined iterator always switched to combined iteration when it observed a file for which `m.HasRangeKeys` was true. This change tweaks the table stats to record the number of `RangeKeySets` within a file. Now, if table stats have been calculated for a file and the lazy combined iterator observes it has no `RangeKeySet`s, the lazy combined iterator will NOT trigger a switch. In Cockroach, this is expected to help when snapshot ingested RANGEKEYDELs. Cockroach lays both a RANGEDEL and RANGEKEYDEL across a range's snapshot sstable. Previously, iterating onto this sstable would unconditionally trigger a switch to combined iteration. Additionally, fix a bug where a combined iterator that was non-lazy due to batch or memtable range keys was incorrectly recorded as lazy. This would cause an unnecessary rebuild of the iterator stack on the first encounter of a range key. Close cockroachdb#1839.
itsbilal
approved these changes
Aug 5, 2022
Contributor
itsbilal
left a comment
There was a problem hiding this comment.
Reviewed 13 of 13 files at r1, 7 of 7 files at r2, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @jbowens)
jbowens
commented
Aug 5, 2022
Contributor
Author
jbowens
left a comment
There was a problem hiding this comment.
TFTR!
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @jbowens)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the lazy combined iterator always switched to combined iteration
when it observed a file for which
m.HasRangeKeyswas true. This change tweaksthe table stats to record the number of
RangeKeySetswithin a file. Now, iftable stats have been calculated for a file and the lazy combined iterator
observes it has no
RangeKeySets, the lazy combined iterator will NOT triggera switch.
In Cockroach, this is expected to help with snapshot ingested RANGEKEYDELs.
Cockroach lays both a RANGEDEL and RANGEKEYDEL across a range's snapshot
sstable. Previously, iterating onto this sstable would unconditionally trigger
a switch to combined iteration.
Additionally, fix a bug where a combined iterator that was non-lazy due to
batch or memtable range keys was incorrectly recorded as lazy. This would cause
an unnecessary rebuild of the iterator stack on the first encounter of a range
key.
Close #1839.