Skip to content

Commit 83451d9

Browse files
committed
read category fix, exempt intent resolution
1 parent ab99b67 commit 83451d9

File tree

7 files changed

+22
-7
lines changed

7 files changed

+22
-7
lines changed

pkg/kv/kvserver/abortspan/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ go_library(
1010
"//pkg/roachpb",
1111
"//pkg/storage",
1212
"//pkg/storage/enginepb",
13+
"//pkg/storage/fs",
1314
"//pkg/util/hlc",
1415
"//pkg/util/log",
1516
"//pkg/util/uuid",

pkg/kv/kvserver/abortspan/abortspan.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/cockroachdb/cockroach/pkg/roachpb"
1414
"github.com/cockroachdb/cockroach/pkg/storage"
1515
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
16+
"github.com/cockroachdb/cockroach/pkg/storage/fs"
1617
"github.com/cockroachdb/cockroach/pkg/util/hlc"
1718
"github.com/cockroachdb/cockroach/pkg/util/log"
1819
"github.com/cockroachdb/cockroach/pkg/util/uuid"
@@ -87,7 +88,9 @@ func (sc *AbortSpan) Get(
8788
) (bool, error) {
8889
// Pull response from disk and read into reply if available.
8990
key := keys.AbortSpanKey(sc.rangeID, txnID)
90-
ok, err := storage.MVCCGetProto(ctx, reader, key, hlc.Timestamp{}, entry, storage.MVCCGetOptions{})
91+
ok, err := storage.MVCCGetProto(ctx, reader, key, hlc.Timestamp{}, entry, storage.MVCCGetOptions{
92+
ReadCategory: fs.AbortSpanReadCategory,
93+
})
9194
return ok, err
9295
}
9396

pkg/storage/engine.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,8 @@ func GetIntent(ctx context.Context, reader Reader, key roachpb.Key) (*roachpb.In
14421442
opts := LockTableIteratorOptions{
14431443
Prefix: true,
14441444
// Ignore Exclusive and Shared locks. We only care about intents.
1445-
MatchMinStr: lock.Intent,
1445+
MatchMinStr: lock.Intent,
1446+
ReadCategory: fs.IntentResolutionReadCategory,
14461447
}
14471448
iter, err := NewLockTableIterator(ctx, reader, opts)
14481449
if err != nil {

pkg/storage/fs/category.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const (
4444
IntentResolutionReadCategory
4545
// BackupReadCategory are reads for backups.
4646
BackupReadCategory
47+
// AbortSpanReadCategory are reads used to check if a txn was aborted.
48+
AbortSpanReadCategory
4749
)
4850

4951
var readCategoryMap = [...]block.Category{

pkg/storage/lock_table_iterator.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ func (opts LockTableIteratorOptions) validate() error {
110110
// toIterOptions converts the LockTableIteratorOptions to IterOptions.
111111
func (opts LockTableIteratorOptions) toIterOptions() IterOptions {
112112
return IterOptions{
113-
Prefix: opts.Prefix,
114-
LowerBound: opts.LowerBound,
115-
UpperBound: opts.UpperBound,
113+
Prefix: opts.Prefix,
114+
LowerBound: opts.LowerBound,
115+
UpperBound: opts.UpperBound,
116+
ReadCategory: opts.ReadCategory,
116117
}
117118
}
118119

pkg/storage/pebble.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ func DefaultPebbleOptions() *pebble.Options {
582582
opts.Experimental.SpanPolicyFunc = spanPolicyFunc
583583
opts.Experimental.UserKeyCategories = userKeyCategories
584584

585-
// Every 5 minutes, log iterators that have been open for more than a minute.
585+
// Every 5 minutes, log iterators that have been open for more than 1 minute.
586586
opts.Experimental.IteratorTracking.PollInterval = 5 * time.Minute
587587
opts.Experimental.IteratorTracking.MaxAge = time.Minute
588588

pkg/storage/pebble_iterator.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,12 +1041,19 @@ func (p *pebbleIterator) assertMVCCInvariants() error {
10411041
return nil
10421042
}
10431043

1044+
var exemptFromTracking = [...]bool{
1045+
fs.BatchEvalReadCategory: true,
1046+
fs.ScanRegularBatchEvalReadCategory: true,
1047+
fs.IntentResolutionReadCategory: true,
1048+
fs.AbortSpanReadCategory: true,
1049+
}
1050+
10441051
func makeIterOptions(
10451052
readCategory fs.ReadCategory, durability DurabilityRequirement,
10461053
) pebble.IterOptions {
10471054
return pebble.IterOptions{
10481055
OnlyReadGuaranteedDurable: durability == GuaranteedDurability,
10491056
Category: readCategory.PebbleCategory(),
1050-
ExemptFromTracking: readCategory == fs.BatchEvalReadCategory || readCategory == fs.ScanRegularBatchEvalReadCategory,
1057+
ExemptFromTracking: int(readCategory) < len(exemptFromTracking) && exemptFromTracking[readCategory],
10511058
}
10521059
}

0 commit comments

Comments
 (0)