Skip to content

Commit

Permalink
Merge #29235
Browse files Browse the repository at this point in the history
29235: *: disable merge queue in more tests r=tschottdorf a=benesch

Take a more aggressive approach to disabling the merge queue in tests.
This commit disables the merge queue in all tests that send a manual
AdminSplit request, unless those tests were explicitly verified to be
safe to run with the merge queue on.

Release note: None

Fix #29085.
Fix #29242.

Co-authored-by: Nikhil Benesch <[email protected]>
  • Loading branch information
craig[bot] and benesch committed Sep 4, 2018
2 parents 1aa2063 + cf83835 commit f63fe69
Show file tree
Hide file tree
Showing 19 changed files with 201 additions and 40 deletions.
2 changes: 2 additions & 0 deletions pkg/ccl/storageccl/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ func runTestImport(t *testing.T, init func(*cluster.Settings)) {
return roachpb.NewError(roachpb.NewAmbiguousResultError(strconv.Itoa(int(r))))
},
},
// Prevent the merge queue from immediately discarding our splits.
DisableMergeQueue: true,
}}

ctx := context.Background()
Expand Down
39 changes: 20 additions & 19 deletions pkg/kv/dist_sender_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ import (
// starting a TestServer, which creates a "real" node and employs a
// distributed sender server-side.

func startNoSplitServer(t *testing.T) (serverutils.TestServerInterface, *client.DB) {
func startNoSplitMergeServer(t *testing.T) (serverutils.TestServerInterface, *client.DB) {
s, _, db := serverutils.StartServer(t, base.TestServerArgs{
Knobs: base.TestingKnobs{
Store: &storage.StoreTestingKnobs{
DisableSplitQueue: true,
DisableMergeQueue: true,
},
},
})
Expand All @@ -67,7 +68,7 @@ func startNoSplitServer(t *testing.T) (serverutils.TestServerInterface, *client.
// index record being read.
func TestRangeLookupWithOpenTransaction(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())

// Create an intent on the meta1 record by writing directly to the
Expand Down Expand Up @@ -367,7 +368,7 @@ func checkReverseScanResults(
// bounds.
func TestMultiRangeBoundedBatchScan(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())
ctx := context.TODO()

Expand Down Expand Up @@ -558,7 +559,7 @@ func TestMultiRangeBoundedBatchScan(t *testing.T) {
// contain two partial responses.
func TestMultiRangeBoundedBatchScanUnsortedOrder(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)

Expand Down Expand Up @@ -597,7 +598,7 @@ func TestMultiRangeBoundedBatchScanUnsortedOrder(t *testing.T) {
// contain two partial responses.
func TestMultiRangeBoundedBatchScanSortedOverlapping(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)

Expand Down Expand Up @@ -666,7 +667,7 @@ func checkResumeSpanDelRangeResults(
// Tests a batch of bounded DelRange() requests.
func TestMultiRangeBoundedBatchDelRange(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)

Expand Down Expand Up @@ -734,7 +735,7 @@ func TestMultiRangeBoundedBatchDelRange(t *testing.T) {
// ResumeSpan.
func TestMultiRangeBoundedBatchDelRangeBoundary(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)

Expand Down Expand Up @@ -780,7 +781,7 @@ func TestMultiRangeBoundedBatchDelRangeBoundary(t *testing.T) {
// overlap.
func TestMultiRangeBoundedBatchDelRangeOverlappingKeys(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)

Expand Down Expand Up @@ -846,7 +847,7 @@ func TestMultiRangeBoundedBatchDelRangeOverlappingKeys(t *testing.T) {
// truncation. In that case, the request is skipped.
func TestMultiRangeEmptyAfterTruncate(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)
db := s.DB()
Expand All @@ -869,7 +870,7 @@ func TestMultiRangeEmptyAfterTruncate(t *testing.T) {
// TestMultiRequestBatchWithFwdAndReverseRequests are disallowed.
func TestMultiRequestBatchWithFwdAndReverseRequests(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)
db := s.DB()
Expand All @@ -891,7 +892,7 @@ func TestMultiRequestBatchWithFwdAndReverseRequests(t *testing.T) {
// DeleteRange and ResolveIntentRange work across ranges.
func TestMultiRangeScanReverseScanDeleteResolve(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)
db := s.DB()
Expand Down Expand Up @@ -955,7 +956,7 @@ func TestMultiRangeScanReverseScanInconsistent(t *testing.T) {
roachpb.INCONSISTENT,
} {
t.Run(rc.String(), func(t *testing.T) {
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)
db := s.DB()
Expand Down Expand Up @@ -1041,7 +1042,7 @@ func TestMultiRangeScanReverseScanInconsistent(t *testing.T) {
// dist sender.
func TestParallelSender(t *testing.T) {
defer leaktest.AfterTest(t)()
s, db := startNoSplitServer(t)
s, db := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())
ctx := context.TODO()

Expand Down Expand Up @@ -1110,7 +1111,7 @@ func initReverseScanTestEnv(s serverutils.TestServerInterface, t *testing.T) *cl
// on a single range.
func TestSingleRangeReverseScan(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())
db := initReverseScanTestEnv(s, t)
ctx := context.TODO()
Expand Down Expand Up @@ -1155,7 +1156,7 @@ func TestSingleRangeReverseScan(t *testing.T) {
// across multiple ranges.
func TestMultiRangeReverseScan(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())
db := initReverseScanTestEnv(s, t)
ctx := context.TODO()
Expand All @@ -1181,7 +1182,7 @@ func TestMultiRangeReverseScan(t *testing.T) {

func TestStopAtRangeBoundary(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)

Expand Down Expand Up @@ -1526,7 +1527,7 @@ func TestStopAtRangeBoundary(t *testing.T) {
// #12603 for more details.
func TestBatchPutWithConcurrentSplit(t *testing.T) {
defer leaktest.AfterTest(t)()
s, db := startNoSplitServer(t)
s, db := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())

// Split first using the default client and scan to make sure that
Expand Down Expand Up @@ -1579,7 +1580,7 @@ func TestBatchPutWithConcurrentSplit(t *testing.T) {
// across multiple ranges while range splits and merges happen.
func TestReverseScanWithSplitAndMerge(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitServer(t)
s, _ := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())
db := initReverseScanTestEnv(s, t)

Expand Down Expand Up @@ -1610,7 +1611,7 @@ func TestReverseScanWithSplitAndMerge(t *testing.T) {

func TestBadRequest(t *testing.T) {
defer leaktest.AfterTest(t)()
s, db := startNoSplitServer(t)
s, db := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())
ctx := context.TODO()

Expand Down
6 changes: 5 additions & 1 deletion pkg/kv/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ func TestRangeSplitsWithWritePressure(t *testing.T) {
// on the same splitKey succeeds.
func TestRangeSplitsWithSameKeyTwice(t *testing.T) {
defer leaktest.AfterTest(t)()
s := createTestDB(t)
s := createTestDBWithContextAndKnobs(t, client.DefaultDBContext(), &storage.StoreTestingKnobs{
DisableScanner: true,
DisableSplitQueue: true,
DisableMergeQueue: true,
})
defer s.Stop()

ctx := context.TODO()
Expand Down
6 changes: 5 additions & 1 deletion pkg/kv/txn_coord_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ func TestTxnCoordSenderCondenseIntentSpans(t *testing.T) {
// Test that the theartbeat loop detects aborted transactions and stops.
func TestTxnCoordSenderHeartbeat(t *testing.T) {
defer leaktest.AfterTest(t)()
s := createTestDB(t)
s := createTestDBWithContextAndKnobs(t, client.DefaultDBContext(), &storage.StoreTestingKnobs{
DisableScanner: true,
DisableSplitQueue: true,
DisableMergeQueue: true,
})
defer s.Stop()
ctx := context.Background()

Expand Down
7 changes: 6 additions & 1 deletion pkg/kv/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/internal/client"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/storage/engine/enginepb"
"github.com/cockroachdb/cockroach/pkg/storage/tscache"
"github.com/cockroachdb/cockroach/pkg/testutils"
Expand Down Expand Up @@ -473,7 +474,11 @@ func TestTxnLongDelayBetweenWritesWithConcurrentRead(t *testing.T) {
// See issue #676 for full details about original bug.
func TestTxnRepeatGetWithRangeSplit(t *testing.T) {
defer leaktest.AfterTest(t)()
s := createTestDB(t)
s := createTestDBWithContextAndKnobs(t, client.DefaultDBContext(), &storage.StoreTestingKnobs{
DisableScanner: true,
DisableSplitQueue: true,
DisableMergeQueue: true,
})
defer s.Stop()

keyA := roachpb.Key("a")
Expand Down
5 changes: 5 additions & 0 deletions pkg/server/intent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
)

// TODO(benesch): move this test to somewhere more specific than package server.
func TestIntentResolution(t *testing.T) {
defer leaktest.AfterTest(t)()

Expand Down Expand Up @@ -111,7 +112,11 @@ func TestIntentResolution(t *testing.T) {
}
return nil
}
// Prevent the merge queue from immediately discarding our splits.
storeKnobs.DisableMergeQueue = true

// TODO(benesch): starting a test server for every test case is needlessly
// inefficient.
s, _, kvDB := serverutils.StartServer(t, base.TestServerArgs{
Knobs: base.TestingKnobs{Store: &storeKnobs}})
defer s.Stopper().Stop(context.TODO())
Expand Down
6 changes: 6 additions & 0 deletions pkg/server/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ func TestNodeStatusWritten(t *testing.T) {
// ========================================
srv, _, kvDB := serverutils.StartServer(t, base.TestServerArgs{
DisableEventLog: true,
Knobs: base.TestingKnobs{
Store: &storage.StoreTestingKnobs{
// Prevent the merge queue from immediately discarding our splits.
DisableMergeQueue: true,
},
},
})
defer srv.Stopper().Stop(context.TODO())
ts := srv.(*TestServer)
Expand Down
18 changes: 16 additions & 2 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,14 @@ func TestAcceptEncoding(t *testing.T) {
// ranges are carried out properly.
func TestMultiRangeScanDeleteRange(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _, db := serverutils.StartServer(t, base.TestServerArgs{})
s, _, db := serverutils.StartServer(t, base.TestServerArgs{
Knobs: base.TestingKnobs{
Store: &storage.StoreTestingKnobs{
// Prevent the merge queue from immediately discarding our splits.
DisableMergeQueue: true,
},
},
})
defer s.Stopper().Stop(context.TODO())
ts := s.(*TestServer)
tds := db.NonTransactionalSender()
Expand Down Expand Up @@ -398,7 +405,14 @@ func TestMultiRangeScanWithMaxResults(t *testing.T) {
for i, tc := range testCases {
t.Run("", func(t *testing.T) {
ctx := context.Background()
s, _, db := serverutils.StartServer(t, base.TestServerArgs{})
s, _, db := serverutils.StartServer(t, base.TestServerArgs{
Knobs: base.TestingKnobs{
Store: &storage.StoreTestingKnobs{
// Prevent the merge queue from immediately discarding our splits.
DisableMergeQueue: true,
},
},
})
defer s.Stopper().Stop(ctx)
ts := s.(*TestServer)
tds := db.NonTransactionalSender()
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/distsqlplan/span_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ func setupRanges(
}
}

// Prevent the merge queue from immediately discarding our splits.
if _, err := db.Exec("SET CLUSTER SETTING kv.range_merge.queue_enabled = false"); err != nil {
t.Fatal(err)
}

tableDesc := sqlbase.GetTableDescriptor(cdb, "t", "test")
// Split every SQL row to its own range.
rowRanges := make([]roachpb.RangeDescriptor, len(values))
Expand Down
3 changes: 3 additions & 0 deletions pkg/storage/client_lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestStoreRangeLease(t *testing.T) {

testutils.RunTrueAndFalse(t, "enableEpoch", func(t *testing.T, enableEpoch bool) {
sc := storage.TestStoreConfig(nil)
sc.TestingKnobs.DisableMergeQueue = true
sc.EnableEpochRangeLeases = enableEpoch
mtc := &multiTestContext{storeConfig: &sc}
defer mtc.Stop()
Expand Down Expand Up @@ -104,6 +105,7 @@ func TestStoreRangeLease(t *testing.T) {
func TestStoreRangeLeaseSwitcheroo(t *testing.T) {
defer leaktest.AfterTest(t)()
sc := storage.TestStoreConfig(nil)
sc.TestingKnobs.DisableMergeQueue = true
sc.EnableEpochRangeLeases = true
mtc := &multiTestContext{storeConfig: &sc}
defer mtc.Stop()
Expand Down Expand Up @@ -169,6 +171,7 @@ func TestStoreRangeLeaseSwitcheroo(t *testing.T) {
func TestStoreGossipSystemData(t *testing.T) {
defer leaktest.AfterTest(t)()
sc := storage.TestStoreConfig(nil)
sc.TestingKnobs.DisableMergeQueue = true
sc.EnableEpochRangeLeases = true
mtc := &multiTestContext{storeConfig: &sc}
defer mtc.Stop()
Expand Down
Loading

0 comments on commit f63fe69

Please sign in to comment.