Skip to content

Commit

Permalink
Merge #37684
Browse files Browse the repository at this point in the history
37684: roachtest: revert not disabling merge queue r=jeffrey-xiao a=jeffrey-xiao

Roachtests need to remain compatible with 19.1 and having the merge
queue enabled when performing a split will throw an error.

Release note: None

Co-authored-by: Jeffrey Xiao <[email protected]>
  • Loading branch information
craig[bot] and jeffrey-xiao committed May 21, 2019
2 parents cb13780 + 5f7fa69 commit d871bda
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/cmd/roachtest/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func registerElectionAfterRestart(r *registry) {
c.Run(ctx, c.Node(1), `./cockroach sql --insecure -e "
CREATE DATABASE IF NOT EXISTS test;
CREATE TABLE test.kv (k INT PRIMARY KEY, v INT);
-- Prevent the merge queue from immediately discarding our splits.
SET CLUSTER SETTING kv.range_merge.queue_enabled = false;
ALTER TABLE test.kv SPLIT AT SELECT generate_series(0, 10000, 100)"`)

start := timeutil.Now()
Expand Down
15 changes: 15 additions & 0 deletions pkg/workload/indexes/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ func (w *indexes) Hooks() workload.Hooks {
return nil
},
PostLoad: func(sqlDB *gosql.DB) error {
// Prevent the merge queue from immediately discarding our splits.
if err := maybeDisableMergeQueue(sqlDB); err != nil {
return err
}
// Split at the beginning of each index so that as long as the
// table has a single index, all writes will be multi-range.
for i := 0; i < w.idxs; i++ {
Expand All @@ -109,6 +113,17 @@ func (w *indexes) Hooks() workload.Hooks {
}
}

func maybeDisableMergeQueue(sqlDB *gosql.DB) error {
var ok bool
if err := sqlDB.QueryRow(
`SELECT count(*) > 0 FROM [ SHOW ALL CLUSTER SETTINGS ] AS _ (v) WHERE v = 'kv.range_merge.queue_enabled'`,
).Scan(&ok); err != nil || !ok {
return err
}
_, err := sqlDB.Exec("SET CLUSTER SETTING kv.range_merge.queue_enabled = false")
return err
}

// Tables implements the Generator interface.
func (w *indexes) Tables() []workload.Table {
// Construct the schema with all indexes.
Expand Down
16 changes: 16 additions & 0 deletions pkg/workload/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,24 @@ func Setup(
return size, nil
}

func maybeDisableMergeQueue(db *gosql.DB) error {
var ok bool
if err := db.QueryRow(
`SELECT count(*) > 0 FROM [ SHOW ALL CLUSTER SETTINGS ] AS _ (v) WHERE v = 'kv.range_merge.queue_enabled'`,
).Scan(&ok); err != nil || !ok {
return err
}
_, err := db.Exec("SET CLUSTER SETTING kv.range_merge.queue_enabled = false")
return err
}

// Split creates the range splits defined by the given table.
func Split(ctx context.Context, db *gosql.DB, table Table, concurrency int) error {
// Prevent the merge queue from immediately discarding our splits.
if err := maybeDisableMergeQueue(db); err != nil {
return err
}

if table.Splits.NumBatches <= 0 {
return nil
}
Expand Down

0 comments on commit d871bda

Please sign in to comment.