Skip to content

Commit b2bab2a

Browse files
craig[bot]fqazi
andcommitted
Merge #149009
149009: roachtest: disable create_table_with_schema_locked for certain tests r=fqazi a=fqazi This series of commits addresses several test failures across different roachtest suites (`costfuzz`, `unoptimized-query-oracle`, `follower-reads`, and `sqlsmith`) that were caused by the `schema_locked` table setting. The multi-region version of these tests preform `ALTER TABLE ... SET LOCALITY`, so these have been modified either to toggle schema_locked or disable it for newly created tables. This patch also fixes a flake inside TestChangefeedNemeses by disabling create_table_with_schema_locked when the legacy schema changer is in use. Fixes: #148927 Fixes: #148940 Fixes: #149007 Fixes: #148976 Fixes: #148975 Fixes: #149002 Fixes: #148994 Fixes: #148995 Fixes: #149005 Fixes: #149000 Fixes: #148999 Fixes: #148996 Fixes: #149018 Fixes: #149015 Fixes: #149013 Fixes: #148997 Fixes: #149047 Fixes: #149045 Fixes: #149017 Fixes: #149014 Fixes: #149019 Fixes: #149016 Fixes: #149012 Release note: None Co-authored-by: Faizan Qazi <[email protected]>
2 parents ad5692c + 77b9512 commit b2bab2a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

pkg/ccl/changefeedccl/nemeses_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ func TestChangefeedNemeses(t *testing.T) {
4040
t.Log("using legacy schema changer")
4141
sqlDB.Exec(t, "SET create_table_with_schema_locked=false")
4242
sqlDB.Exec(t, "SET use_declarative_schema_changer='off'")
43-
sqlDB.Exec(t, "SET CLUSTER SETTING sql.defaults.use_declarative_schema_changer='off'")
43+
sqlDB.Exec(t, "SET CLUSTER SETTING sql.defaults.use_declarative_schema_changer='off'")
44+
sqlDB.Exec(t, "SET CLUSTER SETTING sql.defaults.create_table_with_schema_locked='false'")
45+
4446
}
4547
v, err := cdctest.RunNemesis(f, s.DB, t.Name(), withLegacySchemaChanger, rng, nop)
4648
if err != nil {

pkg/cmd/roachtest/tests/follower_reads.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,13 @@ func initFollowerReadsDB(
527527
}
528528
}
529529

530+
// Disable schema_locked within this since it will modify locality on
531+
// tables.
532+
_, err = db.ExecContext(ctx, "SET create_table_with_schema_locked=false")
533+
require.NoError(t, err)
534+
_, err = db.ExecContext(ctx, "ALTER ROLE ALL SET create_table_with_schema_locked=false")
535+
require.NoError(t, err)
536+
530537
// Create a multi-region database and table.
531538
_, err = db.ExecContext(ctx, `CREATE DATABASE mr_db`)
532539
require.NoError(t, err)

pkg/cmd/roachtest/tests/sqlsmith.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,15 @@ func setupMultiRegionDatabase(t test.Test, conn *gosql.DB, rnd *rand.Rand, logSt
420420
}
421421

422422
for _, table := range tables {
423+
// Locality changes can only be made if schema_locked is toggled.
424+
execStmt(fmt.Sprintf(`ALTER TABLE %s SET (schema_locked=false);`, table.String()))
423425
// Maybe change the locality of the table.
424426
if val := rnd.Intn(3); val == 0 {
425427
execStmt(fmt.Sprintf(`ALTER TABLE %s SET LOCALITY REGIONAL BY ROW;`, table.String()))
426428
} else if val == 1 {
427429
execStmt(fmt.Sprintf(`ALTER TABLE %s SET LOCALITY GLOBAL;`, table.String()))
428430
}
431+
execStmt(fmt.Sprintf(`ALTER TABLE %s SET (schema_locked=true);`, table.String()))
429432
// Else keep the locality as REGIONAL BY TABLE.
430433
}
431434
}

0 commit comments

Comments
 (0)