Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roachtest: revert not disabling merge queue #37684

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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