Skip to content

Commit

Permalink
sql/logictest: add metamorphic param for global MVCC range tombstone
Browse files Browse the repository at this point in the history
This patch adds a metamorphic parameter for the SQL logic tests that
will randomly write a global MVCC range tombstone across the entire user
keyspace during cluster bootstrapping. This should not semantically
affect the test data written above it, but will activate MVCC range
tombstone code paths in the storage layer for testing.

Release justification: non-production code changes

Release note: None
  • Loading branch information
erikgrinaker committed Aug 29, 2022
1 parent 31947b8 commit cf48165
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/sql/logictest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ go_library(
"//pkg/base",
"//pkg/cloud/externalconn/providers",
"//pkg/clusterversion",
"//pkg/kv/kvclient/rangefeed",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/kvserverbase",
"//pkg/roachpb",
"//pkg/security/username",
"//pkg/server",
Expand All @@ -56,6 +58,7 @@ go_library(
"//pkg/testutils/skip",
"//pkg/testutils/sqlutils",
"//pkg/upgrade",
"//pkg/util",
"//pkg/util/envutil",
"//pkg/util/log",
"//pkg/util/randutil",
Expand Down
25 changes: 24 additions & 1 deletion pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ import (
"github.com/cockroachdb/cockroach/pkg/base"
_ "github.com/cockroachdb/cockroach/pkg/cloud/externalconn/providers" // imported to register ExternalConnection providers
"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/server"
Expand All @@ -67,6 +69,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/upgrade"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/randutil"
Expand Down Expand Up @@ -530,6 +533,13 @@ var (
"declarative-corpus", "",
"enables generation and storage of a declarative schema changer corpus",
)

// globalMVCCRangeTombstone will write a global MVCC range tombstone across
// the entire use keyspace during cluster bootstrapping. This should not
// semantically affect the test data written above it, but will activate MVCC
// range tombstone code paths in the storage layer for testing.
globalMVCCRangeTombstone = util.ConstantWithMetamorphicTestBool(
"logictest-global-mvcc-range-tombstone", false)
)

const queryRewritePlaceholderPrefix = "__async_query_rewrite_placeholder"
Expand Down Expand Up @@ -1186,6 +1196,12 @@ func (t *logicTest) newCluster(
// when run with fakedist-disk config, so we'll use a larger limit here.
// There isn't really a downside to doing so.
tempStorageDiskLimit := int64(512 << 20) /* 512 MiB */
// MVCC range tombstones are only available in 22.2 or newer.
enableGlobalMVCCRangeTombstone := globalMVCCRangeTombstone &&
(t.cfg.BootstrapVersion.Equal(roachpb.Version{}) ||
!t.cfg.BootstrapVersion.Less(roachpb.Version{Major: 22, Minor: 2})) &&
(t.cfg.BinaryVersion.Equal(roachpb.Version{}) ||
!t.cfg.BinaryVersion.Less(roachpb.Version{Major: 22, Minor: 2}))

params := base.TestClusterArgs{
ServerArgs: base.TestServerArgs{
Expand All @@ -1197,7 +1213,11 @@ func (t *logicTest) newCluster(
Knobs: base.TestingKnobs{
Store: &kvserver.StoreTestingKnobs{
// The consistency queue makes a lot of noisy logs during logic tests.
DisableConsistencyQueue: true,
DisableConsistencyQueue: true,
GlobalMVCCRangeTombstone: enableGlobalMVCCRangeTombstone,
EvalKnobs: kvserverbase.BatchEvalTestingKnobs{
DisableInitPutFailOnTombstones: enableGlobalMVCCRangeTombstone,
},
},
SQLEvalContext: &eval.TestingKnobs{
AssertBinaryExprReturnTypes: true,
Expand All @@ -1217,6 +1237,9 @@ func (t *logicTest) newCluster(
SQLDeclarativeSchemaChanger: &scexec.TestingKnobs{
BeforeStage: corpusCollectionCallback,
},
RangeFeed: rangefeed.TestingKnobs{
IgnoreOnDeleteRangeError: enableGlobalMVCCRangeTombstone,
},
},
ClusterName: "testclustername",
ExternalIODir: t.sharedIODir,
Expand Down

0 comments on commit cf48165

Please sign in to comment.