Skip to content

Commit

Permalink
release-24.2: storage: fix cases of unencoded key ranges
Browse files Browse the repository at this point in the history
This is a backport of the fixes inside #128043. These are a few cases
where we are passing unencoded key ranges to Pebble for various
operations. This can result in an effective range that starts and/or
ends sooner than intended (part of the key will be treated as the
suffix).

Release justification: fix for Online Restore download phase and for
key range table metrics.

Epic: none
Release note: None
  • Loading branch information
RaduBerinde committed Aug 12, 2024
1 parent 12c14f3 commit 2b743ff
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/storage/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,8 @@ func DefaultPebbleOptions() *pebble.Options {
}
opts.Experimental.ShortAttributeExtractor = shortAttributeExtractorForValues
opts.Experimental.RequiredInPlaceValueBound = pebble.UserKeyPrefixBound{
Lower: keys.LocalRangeLockTablePrefix,
Upper: keys.LocalRangeLockTablePrefix.PrefixEnd(),
Lower: EncodeMVCCKey(MVCCKey{Key: keys.LocalRangeLockTablePrefix}),
Upper: EncodeMVCCKey(MVCCKey{Key: keys.LocalRangeLockTablePrefix.PrefixEnd()}),
}

for i := 0; i < len(opts.Levels); i++ {
Expand Down Expand Up @@ -1076,8 +1076,8 @@ func (p *Pebble) Download(ctx context.Context, span roachpb.Span, copy bool) err
return nil
}
downloadSpan := pebble.DownloadSpan{
StartKey: span.Key,
EndKey: span.EndKey,
StartKey: EncodeMVCCKey(MVCCKey{Key: span.Key}),
EndKey: EncodeMVCCKey(MVCCKey{Key: span.EndKey}),
ViaBackingFileDownload: copy,
}
return p.db.Download(ctx, []pebble.DownloadSpan{downloadSpan})
Expand Down Expand Up @@ -2301,7 +2301,11 @@ func (p *Pebble) PreIngestDelay(ctx context.Context) {

// GetTableMetrics implements the Engine interface.
func (p *Pebble) GetTableMetrics(start, end roachpb.Key) ([]enginepb.SSTableMetricsInfo, error) {
tableInfo, err := p.db.SSTables(pebble.WithKeyRangeFilter(start, end), pebble.WithProperties(), pebble.WithApproximateSpanBytes())
filterOpt := pebble.WithKeyRangeFilter(
EncodeMVCCKey(MVCCKey{Key: start}),
EncodeMVCCKey(MVCCKey{Key: end}),
)
tableInfo, err := p.db.SSTables(filterOpt, pebble.WithProperties(), pebble.WithApproximateSpanBytes())

if err != nil {
return []enginepb.SSTableMetricsInfo{}, err
Expand Down

0 comments on commit 2b743ff

Please sign in to comment.