Skip to content

Commit dd107f0

Browse files
craig[bot]fqazigolgeek
committed
149271: sql: reset schema_locked correctly in a mixed version state r=fqazi a=fqazi Previously, when schema_locked was reset it would always adopt the value from create_table_with_schema_locked. This was incorrect, since this setting should only adopted if the cluster is running on 25.3. This patch adds a version gate in the reset logic. Fixes: #149266 Release note: None 149286: roachtest: add build branch to roachprod's labels r=srosenberg a=golgeek Up to v24.1, roachtests Prometheus targets were discovered in GCP via the gce_sd_configs mechanism. Starting in v24.2, this mechanism has been replaced by an internal helper service, and the gce_sd_configs discovery was later removed from our Prometheus configuration. This configuration update has led to missing scraping targets for all versions prior to v24.2. And the discovery mechanism will need to be reintroduced until all supported releases are EOL. This patch introduces a new label `roachtest-branch` pushed by roachtest during roachprod cluster creation containing the version that is being tested. This will allow filtering in the Prometheus configuration in order to reenable target discovery only for versions prior to v24.2. The patch is purposefully minimal to be backported all the way back to all supported releases. Epic: none Release note: None Co-authored-by: Faizan Qazi <[email protected]> Co-authored-by: Ludovic Leroux <[email protected]>
3 parents c9e7aad + 0f209eb + 2232422 commit dd107f0

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

pkg/cmd/roachtest/spec/cluster_spec.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package spec
77

88
import (
99
"fmt"
10+
"os"
1011
"reflect"
1112
"strings"
1213
"time"
@@ -31,6 +32,9 @@ const (
3132

3233
// Zfs file system.
3334
Zfs fileSystemType = 1
35+
36+
// Extra labels added by roachtest
37+
RoachtestBranch = "roachtest-branch"
3438
)
3539

3640
type MemPerCPU int
@@ -385,7 +389,14 @@ func (s *ClusterSpec) RoachprodOpts(
385389

386390
createVMOpts := vm.DefaultCreateOpts()
387391
// N.B. We set "usage=roachtest" as the default, custom label for billing tracking.
388-
createVMOpts.CustomLabels = map[string]string{"usage": "roachtest"}
392+
createVMOpts.CustomLabels = map[string]string{vm.TagUsage: "roachtest"}
393+
394+
branch := os.Getenv("TC_BUILD_BRANCH")
395+
if branch != "" {
396+
// If the branch is set, we add it as a custom label.
397+
createVMOpts.CustomLabels[RoachtestBranch] = vm.SanitizeLabel(branch)
398+
}
399+
389400
createVMOpts.ClusterName = "" // Will be set later.
390401
if s.Lifetime != 0 {
391402
createVMOpts.Lifetime = s.Lifetime

pkg/sql/logictest/testdata/logic_test/schema_locked

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Intentionally set this to true in 25.2, this setting
2+
# should be ignored.
3+
onlyif config local-mixed-25.2
4+
statement ok
5+
SET create_table_with_schema_locked=true
6+
7+
skipif config local-mixed-25.2
18
statement ok
29
SET create_table_with_schema_locked=false
310

pkg/sql/storageparam/tablestorageparam/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ go_library(
66
importpath = "github.com/cockroachdb/cockroach/pkg/sql/storageparam/tablestorageparam",
77
visibility = ["//visibility:public"],
88
deps = [
9+
"//pkg/clusterversion",
910
"//pkg/sql/catalog/catpb",
1011
"//pkg/sql/catalog/tabledesc",
1112
"//pkg/sql/paramparse",

pkg/sql/storageparam/tablestorageparam/table_storage_param.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"math"
1313
"strings"
1414

15+
"github.com/cockroachdb/cockroach/pkg/clusterversion"
1516
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb"
1617
"github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc"
1718
"github.com/cockroachdb/cockroach/pkg/sql/paramparse"
@@ -608,7 +609,12 @@ var tableParams = map[string]tableParam{
608609
return nil
609610
},
610611
onReset: func(ctx context.Context, po *Setter, evalCtx *eval.Context, key string) error {
611-
po.TableDesc.SchemaLocked = evalCtx.SessionData().CreateTableWithSchemaLocked
612+
schemaLockedDefault := evalCtx.SessionData().CreateTableWithSchemaLocked
613+
// Before 25.3 tables were never created with schema_locked by default.
614+
if !evalCtx.Settings.Version.IsActive(ctx, clusterversion.V25_3) {
615+
schemaLockedDefault = false
616+
}
617+
po.TableDesc.SchemaLocked = schemaLockedDefault
612618
return nil
613619
},
614620
},

0 commit comments

Comments
 (0)