Skip to content

Commit edf0aa4

Browse files
committed
rttanalysis: use SetupEx/ResetEx for multi-database benchmark
Update buildNDatabasesWithMTables to return slices for SetupEx and ResetEx, with each database having its own element. This should make it less likely to encounter txn retry errors during cleanup. Fixes: #156226 Release note: None
1 parent 1c3e1bb commit edf0aa4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pkg/bench/rttanalysis/orm_queries_bench_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -946,8 +946,8 @@ ORDER BY
946946
{
947947
Name: `liquibase migrations on multiple dbs`,
948948
// 15 databases, each with 40 tables.
949-
Setup: liquibaseSetup,
950-
Reset: liquibaseReset,
949+
SetupEx: liquibaseSetup,
950+
ResetEx: liquibaseReset,
951951
Stmt: `SELECT
952952
NULL AS table_cat,
953953
n.nspname AS table_schem,
@@ -1067,16 +1067,18 @@ func buildNTypes(n int) string {
10671067
return b.String()
10681068
}
10691069

1070-
func buildNDatabasesWithMTables(amtDbs int, amtTbls int) (string, string) {
1071-
b := strings.Builder{}
1072-
reset := strings.Builder{}
1070+
func buildNDatabasesWithMTables(amtDbs int, amtTbls int) ([]string, []string) {
1071+
setupEx := make([]string, amtDbs)
1072+
resetEx := make([]string, amtDbs)
10731073
tbls := buildNTables(amtTbls)
10741074
for i := 0; i < amtDbs; i++ {
10751075
db := fmt.Sprintf("d%d", i)
1076+
b := strings.Builder{}
10761077
b.WriteString(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s;\n", db))
1077-
reset.WriteString(fmt.Sprintf("DROP DATABASE %s;\n", db))
10781078
b.WriteString(fmt.Sprintf("USE %s;\n", db))
10791079
b.WriteString(tbls)
1080+
setupEx[i] = b.String()
1081+
resetEx[i] = fmt.Sprintf("DROP DATABASE %s", db)
10801082
}
1081-
return b.String(), reset.String()
1083+
return setupEx, resetEx
10821084
}

0 commit comments

Comments
 (0)