Skip to content

Commit 0d75cc2

Browse files
committed
roachtest: follower-reads/mixed-version handle schema_locked
Previously, we unconditionally attempted to toggle schema_locked in the follower read mixed versions tests, which would fail since versions before 25.3 do not support the new create_table_withschema_locked setting. This patch updates the test to only toggle this setting if the active version for the cluster is 25.3 or greater. Fixes: #149150 Release note: None
1 parent 2a307b2 commit 0d75cc2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

pkg/cmd/roachtest/tests/follower_reads.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"strings"
1818
"time"
1919

20+
"github.com/cockroachdb/cockroach/pkg/clusterversion"
2021
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
2122
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
2223
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
@@ -25,6 +26,7 @@ import (
2526
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/task"
2627
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
2728
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
29+
"github.com/cockroachdb/cockroach/pkg/roachpb"
2830
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
2931
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
3032
"github.com/cockroachdb/cockroach/pkg/roachprod/vm"
@@ -97,7 +99,7 @@ func registerFollowerReads(r registry.Registry) {
9799
}()
98100

99101
rng, _ := randutil.NewPseudoRand()
100-
data := initFollowerReadsDB(ctx, t, t.L(), c, connFunc, connFunc, rng, topology)
102+
data := initFollowerReadsDB(ctx, t, t.L(), c, connFunc, connFunc, rng, topology, clusterversion.Latest.Version())
101103
runFollowerReadsTest(ctx, t, t.L(), c, connFunc, connFunc, rng, topology, rc, data)
102104
},
103105
})
@@ -488,6 +490,7 @@ func initFollowerReadsDB(
488490
connectFunc, systemConnectFunc func(int) *gosql.DB,
489491
rng *rand.Rand,
490492
topology topologySpec,
493+
clusterVersion roachpb.Version,
491494
) (data map[int]int64) {
492495
systemDB := systemConnectFunc(1)
493496
db := connectFunc(1)
@@ -529,10 +532,12 @@ func initFollowerReadsDB(
529532

530533
// Disable schema_locked within this since it will modify locality on
531534
// 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)
535+
if clusterVersion.AtLeast(clusterversion.V25_3.Version()) {
536+
_, err = db.ExecContext(ctx, "SET create_table_with_schema_locked=false")
537+
require.NoError(t, err)
538+
_, err = db.ExecContext(ctx, "ALTER ROLE ALL SET create_table_with_schema_locked=false")
539+
require.NoError(t, err)
540+
}
536541

537542
// Create a multi-region database and table.
538543
_, err = db.ExecContext(ctx, `CREATE DATABASE mr_db`)
@@ -1075,7 +1080,9 @@ func runFollowerReadsMixedVersionTest(
10751080
}
10761081
}
10771082

1078-
data = initFollowerReadsDB(ctx, t, l, c, h.Connect, h.System.Connect, r, topology)
1083+
version, err := h.ClusterVersion(r)
1084+
require.NoError(t, err)
1085+
data = initFollowerReadsDB(ctx, t, l, c, h.Connect, h.System.Connect, r, topology, version)
10791086
return nil
10801087
}
10811088

0 commit comments

Comments
 (0)