From 55ef09a697443f2e172093bcdf5ff7c6fd037c87 Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Wed, 9 Mar 2022 00:26:12 -0500 Subject: [PATCH] storage: make maxItersBeforeSeek metamorphic To prevent maxItersBeforeSeek from hidding inconsistencies between seeking and iterating in the future, the commit makes the value metamorphic, with a range of [0,3). Going forward, unit tests will use different values for this heuristic. Release justification: None. Not intended for v22.1. --- pkg/storage/pebble_mvcc_scanner.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/storage/pebble_mvcc_scanner.go b/pkg/storage/pebble_mvcc_scanner.go index 54b2ccd2c7c7..b5a4ecb12e09 100644 --- a/pkg/storage/pebble_mvcc_scanner.go +++ b/pkg/storage/pebble_mvcc_scanner.go @@ -21,6 +21,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv/kvserver/uncertainty" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/storage/enginepb" + "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/hlc" "github.com/cockroachdb/cockroach/pkg/util/mon" "github.com/cockroachdb/cockroach/pkg/util/protoutil" @@ -28,11 +29,14 @@ import ( "github.com/cockroachdb/pebble" ) -const ( - maxItersBeforeSeek = 0 +// Key value lengths take up 8 bytes (2 x Uint32). +const kvLenSize = 8 - // Key value lengths take up 8 bytes (2 x Uint32). - kvLenSize = 8 +var maxItersBeforeSeek = util.ConstantWithMetamorphicTestRange( + "mvcc-max-iters-before-seek", + 10, /* defaultValue */ + 0, /* min */ + 3, /* max */ ) // Struct to store MVCCScan / MVCCGet in the same binary format as that