Skip to content

Commit 6fd7916

Browse files
craig[bot]rafissyuzefovich
committed
154544: roachtest: update DSC mixed-version test for v25.3-v25.4 r=rafiss a=rafiss Updated the declarative schema changer job compatibility mixed-version test to test statements added to the DSC in v25.3 and v25.4, replacing the previous v24.2-v24.3 version range. The test now validates backward and forward compatibility for: - v25.3: ALTER TABLE ... DROP NOT NULL - v25.4: TRUNCATE, RENAME TABLE, ALTER TABLE ... SET ON UPDATE, ALTER TABLE ... RENAME COLUMN Added cluster version checks to conditionally execute DDLs based on the active cluster version, ensuring the test runs correctly during mixed-version upgrades. fixes #153308 Release note: None 154699: sql: fix label for routine started metrics r=yuzefovich a=yuzefovich During 25.4 in ef4acb4 we merged a change to add counters for stmts started and executed in routines. However, for both types we used `sql.count` label which I think is a mistake - we should use `sql.started.count` for "started" and `sql.count` for "executed" (similar to what we do for stmts outside of the routines). Epic: CRDB-52366 Release note: None Co-authored-by: Rafi Shamim <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]>
3 parents b9f4a61 + 61149e6 + 31b0c9a commit 6fd7916

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

docs/generated/metrics/metrics.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ layers:
664664
derivative: NON_NEGATIVE_DERIVATIVE
665665
- name: sql.routine.delete.started.count
666666
exported_name: sql_routine_delete_started_count
667-
labeled_name: 'sql.count{query_type: routine-started-delete}'
667+
labeled_name: 'sql.started.count{query_type: routine-started-delete}'
668668
description: Number of SQL DELETE statements started within routine invocation
669669
y_axis_label: SQL Statements
670670
type: COUNTER
@@ -674,7 +674,7 @@ layers:
674674
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
675675
- name: sql.routine.delete.started.count.internal
676676
exported_name: sql_routine_delete_started_count_internal
677-
labeled_name: 'sql.count{query_type: routine-started-delete, query_internal: true}'
677+
labeled_name: 'sql.started.count{query_type: routine-started-delete, query_internal: true}'
678678
description: Number of SQL DELETE statements started within routine invocation (internal queries)
679679
y_axis_label: SQL Internal Statements
680680
type: COUNTER
@@ -703,7 +703,7 @@ layers:
703703
derivative: NON_NEGATIVE_DERIVATIVE
704704
- name: sql.routine.insert.started.count
705705
exported_name: sql_routine_insert_started_count
706-
labeled_name: 'sql.count{query_type: routine-started-insert}'
706+
labeled_name: 'sql.started.count{query_type: routine-started-insert}'
707707
description: Number of SQL INSERT statements started within routine invocation
708708
y_axis_label: SQL Statements
709709
type: COUNTER
@@ -713,7 +713,7 @@ layers:
713713
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
714714
- name: sql.routine.insert.started.count.internal
715715
exported_name: sql_routine_insert_started_count_internal
716-
labeled_name: 'sql.count{query_type: routine-started-insert, query_internal: true}'
716+
labeled_name: 'sql.started.count{query_type: routine-started-insert, query_internal: true}'
717717
description: Number of SQL INSERT statements started within routine invocation (internal queries)
718718
y_axis_label: SQL Internal Statements
719719
type: COUNTER
@@ -742,7 +742,7 @@ layers:
742742
derivative: NON_NEGATIVE_DERIVATIVE
743743
- name: sql.routine.select.started.count
744744
exported_name: sql_routine_select_started_count
745-
labeled_name: 'sql.count{query_type: routine-started-select}'
745+
labeled_name: 'sql.started.count{query_type: routine-started-select}'
746746
description: Number of SQL SELECT statements started within routine invocation
747747
y_axis_label: SQL Statements
748748
type: COUNTER
@@ -752,7 +752,7 @@ layers:
752752
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
753753
- name: sql.routine.select.started.count.internal
754754
exported_name: sql_routine_select_started_count_internal
755-
labeled_name: 'sql.count{query_type: routine-started-select, query_internal: true}'
755+
labeled_name: 'sql.started.count{query_type: routine-started-select, query_internal: true}'
756756
description: Number of SQL SELECT statements started within routine invocation (internal queries)
757757
y_axis_label: SQL Internal Statements
758758
type: COUNTER
@@ -781,7 +781,7 @@ layers:
781781
derivative: NON_NEGATIVE_DERIVATIVE
782782
- name: sql.routine.update.started.count
783783
exported_name: sql_routine_update_started_count
784-
labeled_name: 'sql.count{query_type: routine-started-update}'
784+
labeled_name: 'sql.started.count{query_type: routine-started-update}'
785785
description: Number of SQL UPDATE statements started within routine invocation
786786
y_axis_label: SQL Statements
787787
type: COUNTER
@@ -791,7 +791,7 @@ layers:
791791
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
792792
- name: sql.routine.update.started.count.internal
793793
exported_name: sql_routine_update_started_count_internal
794-
labeled_name: 'sql.count{query_type: routine-started-update, query_internal: true}'
794+
labeled_name: 'sql.started.count{query_type: routine-started-update, query_internal: true}'
795795
description: Number of SQL UPDATE statements started within routine invocation (internal queries)
796796
y_axis_label: SQL Internal Statements
797797
type: COUNTER

pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
gosql "database/sql"
1111
"math/rand"
1212

13+
"github.com/cockroachdb/cockroach/pkg/clusterversion"
1314
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
1415
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
1516
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
@@ -27,7 +28,7 @@ func registerDeclarativeSchemaChangerJobCompatibilityInMixedVersion(r registry.R
2728
// This test requires us to come back and change the stmts in executeSupportedDDLs to be those
2829
// supported in the "previous" major release.
2930
r.Add(registry.TestSpec{
30-
Name: "declarative_schema_changer/job-compatibility-mixed-version-V242-V243",
31+
Name: "declarative_schema_changer/job-compatibility-mixed-version-V253-V254",
3132
Owner: registry.OwnerSQLFoundations,
3233
Cluster: r.MakeClusterSpec(4),
3334
// Disabled on IBM because s390x is only built on master and mixed-version
@@ -107,13 +108,19 @@ func executeSupportedDDLs(
107108
return err
108109
}
109110

110-
// DDLs supported in V24_2.
111-
// TODO(sql-foundations): uncomment these when the final 24.2 cluster version
112-
// is created.
113-
v242DDLs := []string{
114-
// `ALTER DATABASE testdb CONFIGURE ZONE USING gc.ttlseconds=1000`,
115-
// `ALTER TABLE testdb.testsc.t CONFIGURE ZONE USING gc.ttlseconds=2000`,
116-
// `COMMENT ON TYPE testdb.testsc.typ IS 'comment'`,
111+
// DDLs supported in V25_3.
112+
v253DDLs := []string{
113+
`ALTER TABLE testdb.testsc.t2 ALTER COLUMN i DROP NOT NULL`,
114+
}
115+
116+
// DDLs supported in V25_4.
117+
v254DDLs := []string{
118+
`TRUNCATE testdb.testsc.t3`,
119+
`ALTER TABLE testdb.testsc.t RENAME TO t_renamed`,
120+
`ALTER TABLE testdb.testsc.t_renamed RENAME TO t`,
121+
`ALTER TABLE testdb.testsc.t2 ALTER COLUMN j SET ON UPDATE j + 1`,
122+
`ALTER TABLE testdb.testsc.t2 RENAME COLUMN k TO k_renamed`,
123+
`ALTER TABLE testdb.testsc.t2 RENAME COLUMN k_renamed TO k`,
117124
}
118125

119126
// Used to clean up our CREATE-d elements after we are done with them.
@@ -130,9 +137,26 @@ func executeSupportedDDLs(
130137
`DROP OWNED BY foo`,
131138
}
132139

133-
ddls := append(v242DDLs, cleanup...)
140+
clusterVersion, err := helper.ClusterVersion(r)
141+
if err != nil {
142+
return err
143+
}
144+
if clusterVersion.AtLeast(clusterversion.V25_3.Version()) {
145+
for _, ddl := range v253DDLs {
146+
if err := helper.ExecWithGateway(r, nodes, ddl); err != nil {
147+
return err
148+
}
149+
}
150+
}
151+
if clusterVersion.AtLeast(clusterversion.V25_4.Version()) {
152+
for _, ddl := range v254DDLs {
153+
if err := helper.ExecWithGateway(r, nodes, ddl); err != nil {
154+
return err
155+
}
156+
}
157+
}
134158

135-
for _, ddl := range ddls {
159+
for _, ddl := range cleanup {
136160
if err := helper.ExecWithGateway(r, nodes, ddl); err != nil {
137161
return err
138162
}

pkg/sql/exec_util.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ var (
11321132
Help: "Number of SQL SELECT statements started within routine invocation",
11331133
Measurement: "SQL Statements",
11341134
Unit: metric.Unit_COUNT,
1135-
LabeledName: "sql.count",
1135+
LabeledName: "sql.started.count",
11361136
StaticLabels: metric.MakeLabelPairs(metric.LabelQueryType, "routine-started-select"),
11371137
Category: metric.Metadata_SQL,
11381138
HowToUse: "This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.",
@@ -1142,7 +1142,7 @@ var (
11421142
Help: "Number of SQL UPDATE statements started within routine invocation",
11431143
Measurement: "SQL Statements",
11441144
Unit: metric.Unit_COUNT,
1145-
LabeledName: "sql.count",
1145+
LabeledName: "sql.started.count",
11461146
StaticLabels: metric.MakeLabelPairs(metric.LabelQueryType, "routine-started-update"),
11471147
Category: metric.Metadata_SQL,
11481148
HowToUse: "This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.",
@@ -1152,7 +1152,7 @@ var (
11521152
Help: "Number of SQL INSERT statements started within routine invocation",
11531153
Measurement: "SQL Statements",
11541154
Unit: metric.Unit_COUNT,
1155-
LabeledName: "sql.count",
1155+
LabeledName: "sql.started.count",
11561156
StaticLabels: metric.MakeLabelPairs(metric.LabelQueryType, "routine-started-insert"),
11571157
Category: metric.Metadata_SQL,
11581158
HowToUse: "This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.",
@@ -1162,7 +1162,7 @@ var (
11621162
Help: "Number of SQL DELETE statements started within routine invocation",
11631163
Measurement: "SQL Statements",
11641164
Unit: metric.Unit_COUNT,
1165-
LabeledName: "sql.count",
1165+
LabeledName: "sql.started.count",
11661166
StaticLabels: metric.MakeLabelPairs(metric.LabelQueryType, "routine-started-delete"),
11671167
Category: metric.Metadata_SQL,
11681168
HowToUse: "This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.",

0 commit comments

Comments
 (0)