From a3a9e150adf7a693b91802899601513473a195c9 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Fri, 22 Sep 2023 13:28:04 +0000 Subject: [PATCH] sql/tests: avoid contention in RSG test 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 --- pkg/sql/tests/rsg_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/sql/tests/rsg_test.go b/pkg/sql/tests/rsg_test.go index f6d22e96b221..387aa50c9ef3 100644 --- a/pkg/sql/tests/rsg_test.go +++ b/pkg/sql/tests/rsg_test.go @@ -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", } @@ -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.