Skip to content

Commit

Permalink
sql/tests: avoid contention in RSG test
Browse files Browse the repository at this point in the history
TestRandomSyntaxSchemaChangeColumn would always operate on the same
table, which would cause many schema changes to get queued up, since
everything happens concurrently. This isn't even that realistic, so now
it does the schema change on one of 50 tables randomly.

Release note: None
  • Loading branch information
rafiss committed Sep 22, 2023
1 parent 65df41b commit a3a9e15
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/sql/tests/rsg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ func TestRandomSyntaxSchemaChangeColumn(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

numTables := *flagRSGGoRoutines
roots := []string{
"alter_table_cmd",
}
Expand All @@ -499,13 +500,18 @@ func TestRandomSyntaxSchemaChangeColumn(t *testing.T) {
if err := db.exec(t, ctx, "SET CLUSTER SETTING sql.catalog.descriptor_lease_duration = '30s'"); err != nil {
return err
}
return db.exec(t, ctx, `
CREATE DATABASE ident;
CREATE TABLE ident.ident (ident decimal);
`)
if err := db.exec(t, ctx, `CREATE DATABASE ident;`); err != nil {
return err
}
for i := 0; i < numTables; i++ {
if err := db.exec(t, ctx, fmt.Sprintf(`CREATE TABLE ident.ident%d (ident decimal);`, i)); err != nil {
return err
}
}
return nil
}, func(ctx context.Context, db *verifyFormatDB, r *rsg.RSG) error {
n := r.Intn(len(roots))
s := fmt.Sprintf("ALTER TABLE ident.ident %s", r.Generate(roots[n], 500))
s := fmt.Sprintf("ALTER TABLE ident.ident%d %s", r.Intn(numTables), r.Generate(roots[n], 500))
// Execute with a resettable timeout, where we allow up to N go-routines worth
// of resets. This should be the maximum theoretical time we can get
// stuck behind other work.
Expand Down

0 comments on commit a3a9e15

Please sign in to comment.