From f45839e50c8fddcda4c3694c8c841a2c2eb78736 Mon Sep 17 00:00:00 2001 From: Radu Berinde Date: Mon, 12 Aug 2024 09:44:04 -0700 Subject: [PATCH] release-24.2: storage: fix cases of unencoded key ranges 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 for key range table metrics. Epic: none Release note: None --- pkg/storage/pebble.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/storage/pebble.go b/pkg/storage/pebble.go index d1f2dfadca0b..c98b2a1f3756 100644 --- a/pkg/storage/pebble.go +++ b/pkg/storage/pebble.go @@ -789,8 +789,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++ { @@ -2360,7 +2360,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