Skip to content

pkg/storage: support suffix replacement on MVCC interval collector#76327

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nicktrav:nickt.block-prop-collector-suffix
Feb 12, 2022
Merged

pkg/storage: support suffix replacement on MVCC interval collector#76327
craig[bot] merged 1 commit intocockroachdb:masterfrom
nicktrav:nickt.block-prop-collector-suffix

Conversation

@nicktrav
Copy link
Copy Markdown
Collaborator

@nicktrav nicktrav commented Feb 9, 2022

The SuffixReplaceableBlockCollector interface was added to to Pebble
in cockroachdb/pebble#1377, which allows a block property collector to
indicate that it supports being updated during suffix replacement.

The existing pebbleDataBlockMVCCTimeIntervalCollector block property
collector does not currently support suffix replacement. However, given
a new suffix, the interval for a block can be trivially calculated.

Implement the SuffixReplaceableBlockCollector interface.

Release note: None

@nicktrav nicktrav requested review from dt and sumeerbhola February 9, 2022 19:50
@nicktrav nicktrav requested a review from a team as a code owner February 9, 2022 19:50
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@nicktrav nicktrav requested a review from jbowens February 10, 2022 02:28
Copy link
Copy Markdown
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

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

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


-- commits, line 4 at r1:
... added to Pebble ...


pkg/storage/pebble.go, line 386 at r1 (raw file):

// add collects the given slice in the collector. The slice may be an entire
// encoded MVCC key, or the suffix of an encoded key. In the case of the latter,
// the slice must include the sentinel byte.

The definition of the suffix does not include the sentinel byte as described in

// The motivation for the sentinel is that we configure the underlying storage
// engine (Pebble) with a Split function that can be used for constructing
// Bloom filters over just the Key field. However, the encoded Key must also
// look like an encoded EngineKey. By splitting, at Key + \x00, the Key looks
// like an EngineKey with no Version.

Which is why we needed the code in
if aSep == -1 && bSep == -1 {
aSep, bSep = 0, 0 // comparing bare suffixes
}

The `SuffixReplaceableBlockCollector` interface was added to Pebble in
cockroachdb/pebble#1377, which allows a block property collector to
indicate that it supports being updated during suffix replacement.

The existing `pebbleDataBlockMVCCTimeIntervalCollector` block property
collector does not currently support suffix replacement. However, given
a new suffix, the interval for a block can be trivially calculated.

Implement the `SuffixReplaceableBlockCollector` interface.

Release note: None
@nicktrav nicktrav force-pushed the nickt.block-prop-collector-suffix branch from 8003e66 to 130d69f Compare February 10, 2022 23:52
Copy link
Copy Markdown
Collaborator Author

@nicktrav nicktrav left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dt, @jbowens, and @sumeerbhola)


-- commits, line 4 at r1:

Previously, sumeerbhola wrote…

... added to Pebble ...

Done.


pkg/storage/pebble.go, line 386 at r1 (raw file):

Previously, sumeerbhola wrote…

The definition of the suffix does not include the sentinel byte as described in

// The motivation for the sentinel is that we configure the underlying storage
// engine (Pebble) with a Split function that can be used for constructing
// Bloom filters over just the Key field. However, the encoded Key must also
// look like an encoded EngineKey. By splitting, at Key + \x00, the Key looks
// like an EngineKey with no Version.

Which is why we needed the code in
if aSep == -1 && bSep == -1 {
aSep, bSep = 0, 0 // comparing bare suffixes
}

Ah, missed that. I was using "suffix" in a more general "trailing bytes" sense. I didn't realize "suffix" has a precise definition in this context (MVCC timestamp + length byte; no sentinel).

If I'm understanding correctly now, this method should only receive either:

  • a full EngineKey (which will include the sentinel) when called from Add; or
  • a bare suffix (no sentinel), when called from UpdateKeySuffixes

I added some error handling and some additional test cases.

Copy link
Copy Markdown
Collaborator

@sumeerbhola sumeerbhola 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 r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @dt, @jbowens, and @sumeerbhola)

@nicktrav
Copy link
Copy Markdown
Collaborator Author

TFTR!

bors r=sumeerbhola

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 12, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 12, 2022

Build succeeded:

@craig craig bot merged commit d58220f into cockroachdb:master Feb 12, 2022
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