Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
134266: roachtest: give longer timeout for MR schema changes r=yuzefovich a=yuzefovich

We just saw a test failure where `ALTER TABLE ... SET LOCALITY ...` stmt timed out when setting up the MR database due to the stmt timeout of 60s set on the connection. In the logs it appeared that the schema change actually succeeded, so prevent this type of failures we'll temporarily increase the timeout by 3x for all MR setup queries.

Fixes: cockroachdb#134057.

Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
craig[bot] and yuzefovich committed Nov 6, 2024
2 parents d0e07ef + 6343570 commit 0d9dc81
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions pkg/cmd/roachtest/tests/sqlsmith.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,26 @@ WITH into_db = 'defaultdb', unsafe_restore_incompatible_version;
// setupMultiRegionDatabase is used to set up a multi-region database.
func setupMultiRegionDatabase(t test.Test, conn *gosql.DB, rnd *rand.Rand, logStmt func(string)) {
t.Helper()

execStmt := func(stmt string) {
logStmt(stmt)
if _, err := conn.Exec(stmt); err != nil {
t.Fatal(err)
}
}

// If we have a stmt timeout set on the session, then increase it 3x given
// that schema changes below can take non-trivial amount of time.
row := conn.QueryRow("SHOW statement_timeout")
var stmtTimeout int
if err := row.Scan(&stmtTimeout); err != nil {
t.Fatal(err)
} else if stmtTimeout != 0 {
t.L().Printf("temporarily increasing the statement timeout")
execStmt(fmt.Sprintf("SET statement_timeout = %d", 3*stmtTimeout))
defer execStmt(fmt.Sprintf("SET statement_timeout = %d", stmtTimeout))
}

regionsSet := make(map[string]struct{})
var region, zone string
rows, err := conn.Query("SHOW REGIONS FROM CLUSTER")
Expand All @@ -390,13 +410,6 @@ func setupMultiRegionDatabase(t test.Test, conn *gosql.DB, rnd *rand.Rand, logSt
t.Fatal(errors.New("no regions, cannot run multi-region config"))
}

execStmt := func(stmt string) {
logStmt(stmt)
if _, err := conn.Exec(stmt); err != nil {
t.Fatal(err)
}
}

for i, region := range regionList {
if i == 0 {
execStmt(fmt.Sprintf(`ALTER DATABASE defaultdb SET PRIMARY REGION "%s";`, region))
Expand Down

0 comments on commit 0d9dc81

Please sign in to comment.