Skip to content
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

storageccl: use the new PebbleIterator in ExternalSSTReader #84666

Merged
merged 1 commit into from
Jul 21, 2022

Conversation

msbutler
Copy link
Collaborator

@msbutler msbutler commented Jul 19, 2022

This PR refactors all call sites of ExternalSSTReader(), to support using the
new PebbleIterator, which has baked in range key support. Most notably, this
PR replaces the multiIterator used in the restore data processor with the
PebbleSSTIterator.

This patch is apart of a larger effort to teach backup and restore about MVCC
bulk operations. Next, the readAsOfIterator will need to learn how to
deal with range keys.

Informs #71155

This PR addresses a bug created in #83984: loop variables in
ExternalSSTReader were captured by reference, leading to roachtest failures
(#84240, #84162).

Informs #71155

Fixes: #84240, #84162, #84181

Release note: none

@msbutler msbutler requested review from dt, erikgrinaker and jbowens July 19, 2022 18:44
@msbutler msbutler requested review from a team as code owners July 19, 2022 18:44
@msbutler msbutler requested a review from a team July 19, 2022 18:44
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@msbutler msbutler force-pushed the butler-pebble-repro branch from 1b52ea2 to c840968 Compare July 19, 2022 18:51
Copy link
Contributor

@erikgrinaker erikgrinaker 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 at a high level.

pkg/ccl/storageccl/external_sst_reader.go Outdated Show resolved Hide resolved
pkg/ccl/storageccl/external_sst_reader.go Outdated Show resolved Hide resolved
pkg/ccl/storageccl/external_sst_reader.go Outdated Show resolved Hide resolved
@msbutler msbutler force-pushed the butler-pebble-repro branch from c840968 to 6ffa08e Compare July 19, 2022 18:59
var reader sstable.ReadableFile = raw
for i, basename := range filenames {
// prevent capturing the loop variables by reference when defining openAt below.
basename := basename
Copy link
Collaborator Author

@msbutler msbutler Jul 19, 2022

Choose a reason for hiding this comment

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

@jbowens if I comment these local vars out, the unit test I wrote in the PR still passes :(. You mentioned that the roachtest failures occur at block boundaries. I assume this occurs when pebbleIterator.Iter.ExternalFiles[i].ReadAt is called. Do you have any tips on how I could construct the SSTs in the unit test to ensure the test hits block boundaries? Maybe this is overkill, since we no know the bug is squashed and the test still adds good coverage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it trigger if you vary the number of keys per-file, eg, 10, 100, 1000?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nope. I also changed the sst's to partially overlap, and still no repro. They currently look like this:

// t3               a500--------------------a10000
//
// t2      a50--------------a1000
//
// t1   a0----a100

@msbutler msbutler self-assigned this Jul 19, 2022
@msbutler msbutler removed the request for review from a team July 19, 2022 20:08
@msbutler msbutler force-pushed the butler-pebble-repro branch 3 times, most recently from 9b2bb35 to f2038ee Compare July 20, 2022 15:08
This PR refactors all call sites of ExternalSSTReader(), to support using the
new PebbleIterator, which has baked in range key support. Most notably, this
PR replaces the multiIterator used in the restore data processor with the
PebbleSSTIterator.

This patch is apart of a larger effort to teach backup and restore about MVCC
bulk operations. Next, the readAsOfIterator will need to learn how to
deal with range keys.

Informs cockroachdb#71155

This PR addresses a bug created in cockroachdb#83984: loop variables in
ExternalSSTReader were captured by reference, leading to roachtest failures
(cockroachdb#84240, cockroachdb#84162).

Informs #71155i

Fixes: cockroachdb#84240, cockroachdb#84162, cockroachdb#84181

Release note: none
@msbutler msbutler force-pushed the butler-pebble-repro branch from f2038ee to 85cd5ab Compare July 20, 2022 19:00
@msbutler
Copy link
Collaborator Author

msbutler commented Jul 21, 2022

I've got a couple of PRs waiting for this to merge. So I'm going to merge this and file an issue for myself to further investigate a test that covers the capture by reference issue.

@msbutler
Copy link
Collaborator Author

bors r=erikgrinaker

@craig
Copy link
Contributor

craig bot commented Jul 21, 2022

Build succeeded:

@craig craig bot merged commit cbfceb7 into cockroachdb:master Jul 21, 2022
@msbutler msbutler deleted the butler-pebble-repro branch July 21, 2022 14:22
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.

roachtest: backupTPCC failed
4 participants