Skip to content

storage: allow multiple iterators in pebbleReadOnly and pebbleBatch#81195

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
erikgrinaker:pebble-multi-iter
May 16, 2022
Merged

storage: allow multiple iterators in pebbleReadOnly and pebbleBatch#81195
craig[bot] merged 1 commit intocockroachdb:masterfrom
erikgrinaker:pebble-multi-iter

Conversation

@erikgrinaker
Copy link
Copy Markdown
Contributor

Partial resubmit of #79291, which was merged into the mvcc-range-tombstones branch.


Previously, pebbleReadOnly and pebbleBatch only supported a single
concurrent iterator of a given type, as this iterator was reused between
NewMVCCIterator calls. Attempts to create an additional iterator would
panic with "iterator already in use".

Time-bound iterators were excluded from this reuse, and always created
from scratch, so they sidestepped this limitation. However, we will soon
make these iterators reusable too via a new SetOptions() method in
Pebble. When TBIs also become reusable, this will cause
MVCCIncrementalIterator to panic with "iterator already in use",
because it always creates two concurrent iterators: one regular and one
time-bound.

This patch therefore ensures all Reader implementations support
multiple concurrent iterators, by cloning the existing cached iterator
if it is already in use. This also preserves the pinned engine state for
the new iterator.

Release note: None

Previously, `pebbleReadOnly` and `pebbleBatch` only supported a single
concurrent iterator of a given type, as this iterator was reused between
`NewMVCCIterator` calls. Attempts to create an additional iterator would
panic with "iterator already in use".

Time-bound iterators were excluded from this reuse, and always created
from scratch, so they sidestepped this limitation. However, we will soon
make these iterators reusable too via a new `SetOptions()` method in
Pebble. When TBIs also become reusable, this will cause
`MVCCIncrementalIterator` to panic with "iterator already in use",
because it always creates two concurrent iterators: one regular and one
time-bound.

This patch therefore ensures all `Reader` implementations support
multiple concurrent iterators, by cloning the existing cached iterator
if it is already in use. This also preserves the pinned engine state for
the new iterator.

Release note: None
@erikgrinaker erikgrinaker self-assigned this May 11, 2022
@erikgrinaker erikgrinaker requested a review from a team as a code owner May 11, 2022 16:53
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

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

:lgtm:

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @aliher1911, @nicktrav, and @sumeerbhola)

@erikgrinaker
Copy link
Copy Markdown
Contributor Author

TFTR!

bors r=jbowens

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 16, 2022

Build succeeded:

@craig craig bot merged commit e2f3965 into cockroachdb:master May 16, 2022
@erikgrinaker erikgrinaker deleted the pebble-multi-iter branch May 17, 2022 16:27
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.

3 participants