Skip to content

Commit

Permalink
roachtest: set timeout in MR costfuzz, unoptimized-query-oracle
Browse files Browse the repository at this point in the history
We weren't setting a couple of session variables on the second
connection opened for multi-region costfuzz and
unoptimized-query-oracle, including statement_timeout.

Fixes: #131147
Fixes: #131153
Fixes: #131166
Fixes: #131344

Release note: None
  • Loading branch information
michae2 committed Sep 25, 2024
1 parent e523823 commit 0bf75ff
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions pkg/cmd/roachtest/tests/query_comparison_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,34 @@ func runOneRoundQueryComparison(
fmt.Fprint(failureLog, "\n")
}

connSetup := func(conn *gosql.DB) {
setStmtTimeout := fmt.Sprintf("SET statement_timeout='%s';", statementTimeout.String())
t.Status("setting statement_timeout")
t.L().Printf("statement timeout:\n%s", setStmtTimeout)
if _, err := conn.Exec(setStmtTimeout); err != nil {
t.Fatal(err)
}
logStmt(setStmtTimeout)

setUnconstrainedStmt := "SET unconstrained_non_covering_index_scan_enabled = true;"
t.Status("setting unconstrained_non_covering_index_scan_enabled")
t.L().Printf("\n%s", setUnconstrainedStmt)
if _, err := conn.Exec(setUnconstrainedStmt); err != nil {
logStmt(setUnconstrainedStmt)
t.Fatal(err)
}
logStmt(setUnconstrainedStmt)
}

node := 1
conn := c.Conn(ctx, t.L(), node)

rnd, seed := randutil.NewTestRand()
t.L().Printf("seed: %d", seed)
t.L().Printf("setupName: %s", qct.setupName)

connSetup(conn)

if qct.setupName == "workload-replay" {

logTest := func(logStr string, logType string) {
Expand Down Expand Up @@ -309,23 +330,6 @@ func runOneRoundQueryComparison(
}
}

setStmtTimeout := fmt.Sprintf("SET statement_timeout='%s';", statementTimeout.String())
t.Status("setting statement_timeout")
t.L().Printf("statement timeout:\n%s", setStmtTimeout)
if _, err := conn.Exec(setStmtTimeout); err != nil {
t.Fatal(err)
}
logStmt(setStmtTimeout)

setUnconstrainedStmt := "SET unconstrained_non_covering_index_scan_enabled = true;"
t.Status("setting unconstrained_non_covering_index_scan_enabled")
t.L().Printf("\n%s", setUnconstrainedStmt)
if _, err := conn.Exec(setUnconstrainedStmt); err != nil {
logStmt(setUnconstrainedStmt)
t.Fatal(err)
}
logStmt(setUnconstrainedStmt)

conn2 := conn
node2 := 1
if qct.isMultiRegion {
Expand All @@ -336,6 +340,7 @@ func runOneRoundQueryComparison(
node2 = rnd.Intn(qct.nodeCount-1) + 2
t.Status(fmt.Sprintf("running some queries from node %d with conn1 and some queries from node %d with conn2", node, node2))
conn2 = c.Conn(ctx, t.L(), node2)
connSetup(conn2)
}

// Initialize a smither that generates only INSERT and UPDATE statements with
Expand Down

0 comments on commit 0bf75ff

Please sign in to comment.