From 293ff1d889a1bcc38084516a34a4295cc64c0420 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Wed, 17 Jul 2024 17:46:01 -0400 Subject: [PATCH 1/2] roachtest: avoid pooling in DSC job compat test This makes sure that session variables have their intended effect. Release note: None --- ...job_compatibility_in_declarative_schema_changer.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go b/pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go index 4beed2f1f657..f9c2dbe4013b 100644 --- a/pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go +++ b/pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go @@ -178,13 +178,8 @@ func runDeclarativeSchemaChangerJobCompatibilityInMixedVersion( // Ensure that the declarative schema changer is off so that we do not get failures related to unimplemented // statements in the dsc. - for _, node := range c.All() { - if err := helper.ExecWithGateway(r, option.NodeListOption{node}, "SET use_declarative_schema_changer = off"); err != nil { - return err - } - } - setUpQuery := ` +SET use_declarative_schema_changer = off; CREATE DATABASE IF NOT EXISTS testdb; CREATE SCHEMA IF NOT EXISTS testdb.testsc; CREATE TABLE IF NOT EXISTS testdb.testsc.t (i INT PRIMARY KEY, j INT NOT NULL, INDEX idx (j), CONSTRAINT check_j CHECK (j > 0)); @@ -205,7 +200,11 @@ CREATE VIEW IF NOT EXISTS testdb.testsc.v AS (SELECT i*2 FROM testdb.testsc.t); // so that we don't fall back to legacy schema changer implicitly. // Being explicit can help catch bugs that will otherwise be // buried by the fallback. + // To make sure the session variables are applied correctly, we limit each + // connection pool to have at most 1 connection. for _, node := range c.All() { + db := helper.Connect(node) + db.SetMaxOpenConns(1) if err := helper.ExecWithGateway(r, option.NodeListOption{node}, "SET use_declarative_schema_changer = unsafe_always"); err != nil { return err } From 2614bab5e84f6838302efeef58d26c7ea59ffc4d Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Wed, 17 Jul 2024 17:45:20 -0400 Subject: [PATCH 2/2] roachtest: rename DSC job compat test for 24.3 Release note: None --- ...atibility_in_declarative_schema_changer.go | 45 ++++--------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go b/pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go index f9c2dbe4013b..e6bf468bccf8 100644 --- a/pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go +++ b/pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go @@ -31,7 +31,7 @@ func registerDeclarativeSchemaChangerJobCompatibilityInMixedVersion(r registry.R // This test requires us to come back and change the stmts in executeSupportedDDLs to be those // supported in the "previous" major release. r.Add(registry.TestSpec{ - Name: "declarative_schema_changer/job-compatibility-mixed-version-V241-V242", + Name: "declarative_schema_changer/job-compatibility-mixed-version-V242-V243", Owner: registry.OwnerSQLFoundations, Cluster: r.MakeClusterSpec(4), CompatibleClouds: registry.AllExceptAWS, @@ -97,40 +97,13 @@ func executeSupportedDDLs( return err } - // DDLs supported in V23_2. - v232DDLs := []string{ - `COMMENT ON DATABASE testdb IS 'this is a database comment'`, - `COMMENT ON SCHEMA testdb.testsc IS 'this is a schema comment'`, - `COMMENT ON TABLE testdb.testsc.t IS 'this is a table comment'`, - `COMMENT ON COLUMN testdb.testsc.t.i IS 'this is a column comment'`, - `COMMENT ON INDEX testdb.testsc.t@idx IS 'this is a index comment'`, - `COMMENT ON CONSTRAINT check_j ON testdb.testsc.t IS 'this is a constraint comment'`, - `ALTER TABLE testdb.testsc.t ADD COLUMN k INT DEFAULT 35`, - `ALTER TABLE testdb.testsc.t DROP COLUMN k`, - `ALTER TABLE testdb.testsc.t2 ADD PRIMARY KEY (i)`, - `ALTER TABLE testdb.testsc.t2 ALTER PRIMARY KEY USING COLUMNS (j)`, - `CREATE FUNCTION fn(a INT) RETURNS INT AS 'SELECT a*a' LANGUAGE SQL`, - `CREATE INDEX ON testdb.testsc.t3 (i)`, - `ALTER TABLE testdb.testsc.t2 ALTER COLUMN k SET NOT NULL`, - `ALTER TABLE testdb.testsc.t2 ALTER PRIMARY KEY USING COLUMNS (k) USING HASH`, - `ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT j_unique UNIQUE WITHOUT INDEX (k)`, - `ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT j_unique_not_valid UNIQUE WITHOUT INDEX (k) NOT VALID`, - `ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT fk FOREIGN KEY (j) REFERENCES testdb.testsc.t2 (j)`, - `ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT fk_not_valid FOREIGN KEY (j) REFERENCES testdb.testsc.t2 (j) NOT VALID`, - `ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT check_positive CHECK (j > 0)`, - `ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT check_positive_not_valid CHECK (j > 0) NOT VALID`, - `ALTER TABLE testdb.testsc.t3 DROP CONSTRAINT check_positive`, - `ALTER TABLE testdb.testsc.t3 VALIDATE CONSTRAINT check_positive_not_valid`, - } - - // DDLs supported in V24_1. - v241DDLs := []string{ - `ALTER TABLE testdb.testsc.t ADD COLUMN k int, ADD COLUMN l int, DROP COLUMN l`, - `ALTER TABLE testdb.testsc.t ALTER COLUMN k SET DEFAULT 42`, - `ALTER TABLE testdb.testsc.t ALTER COLUMN k DROP DEFAULT`, - `CREATE DATABASE testdb2`, - `CREATE SCHEMA testdb2.testsc`, - `CREATE SEQUENCE testdb2.testsc.s`, + // DDLs supported in V24_2. + // TODO(sql-foundations): uncomment these when the final 24.2 cluster version + // is created. + v242DDLs := []string{ + // `ALTER DATABASE testdb CONFIGURE ZONE USING gc.ttlseconds=1000`, + // `ALTER TABLE testdb.testsc.t CONFIGURE ZONE USING gc.ttlseconds=2000`, + // `COMMENT ON TYPE testdb.testsc.typ IS 'comment'`, } // Used to clean up our CREATE-d elements after we are done with them. @@ -151,7 +124,7 @@ func executeSupportedDDLs( `DROP DATABASE testdb2 CASCADE`, } - ddls := append(v232DDLs, append(v241DDLs, cleanup...)...) + ddls := append(v242DDLs, cleanup...) for _, ddl := range ddls { if err := helper.ExecWithGateway(r, nodes, ddl); err != nil {