Skip to content

db: only switch to combined iteration on RangeKeySet keys#1856

Merged
jbowens merged 1 commit intocockroachdb:masterfrom
jbowens:lazy-sets-only
Aug 5, 2022
Merged

db: only switch to combined iteration on RangeKeySet keys#1856
jbowens merged 1 commit intocockroachdb:masterfrom
jbowens:lazy-sets-only

Conversation

@jbowens
Copy link
Copy Markdown
Contributor

@jbowens jbowens commented Aug 5, 2022

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 RangeKeySets, the lazy combined iterator will NOT trigger
a 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.

@jbowens jbowens requested a review from a team August 5, 2022 16:04
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

@jbowens jbowens left a comment

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor

@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.

:lgtm:

Reviewed 13 of 13 files at r1, 7 of 7 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jbowens)

Copy link
Copy Markdown
Contributor Author

@jbowens jbowens 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! all files reviewed, all discussions resolved (waiting on @jbowens)

@jbowens jbowens merged commit eb306b9 into cockroachdb:master Aug 5, 2022
@jbowens jbowens deleted the lazy-sets-only branch August 5, 2022 22:25
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.

db: avoid triggering combined iteration on only RANGEKEYDELs

3 participants