Skip to content

Commit a3014f0

Browse files
committed
spanconfig: version gate meta1/meta2 split point in spanconfig
This commit adds a version gate around the spanconfig split point between meta1 and meta2 to avoid scenarios during a rolling upgrade where the job switches back and forth between a v25.4 and a v26.1 versions, which could result in the split point be created a removed multiple times. This was originally done in #119594. Fixes: #119421 Release note: None
1 parent b86f9f7 commit a3014f0

File tree

8 files changed

+113
-10
lines changed

8 files changed

+113
-10
lines changed

docs/generated/settings/settings-for-tenants.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,4 +426,4 @@ trace.zipkin.collector string the address of a Zipkin instance to receive trace
426426
ui.database_locality_metadata.enabled boolean true if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute application
427427
ui.default_timezone string the default timezone used to format timestamps in the ui application
428428
ui.display_timezone enumeration etc/utc the timezone used to format timestamps in the ui. This setting is deprecatedand will be removed in a future version. Use the 'ui.default_timezone' setting instead. 'ui.default_timezone' takes precedence over this setting. [etc/utc = 0, america/new_york = 1] application
429-
version version 1000025.4-upgrading-to-1000026.1-step-002 set the active cluster version in the format '<major>.<minor>' application
429+
version version 1000025.4-upgrading-to-1000026.1-step-004 set the active cluster version in the format '<major>.<minor>' application

docs/generated/settings/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,6 @@
385385
<tr><td><div id="setting-ui-database-locality-metadata-enabled" class="anchored"><code>ui.database_locality_metadata.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
386386
<tr><td><div id="setting-ui-default-timezone" class="anchored"><code>ui.default_timezone</code></div></td><td>string</td><td><code></code></td><td>the default timezone used to format timestamps in the ui</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
387387
<tr><td><div id="setting-ui-display-timezone" class="anchored"><code>ui.display_timezone</code></div></td><td>enumeration</td><td><code>etc/utc</code></td><td>the timezone used to format timestamps in the ui. This setting is deprecatedand will be removed in a future version. Use the &#39;ui.default_timezone&#39; setting instead. &#39;ui.default_timezone&#39; takes precedence over this setting. [etc/utc = 0, america/new_york = 1]</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
388-
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000025.4-upgrading-to-1000026.1-step-002</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
388+
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000025.4-upgrading-to-1000026.1-step-004</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
389389
</tbody>
390390
</table>

pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ go_test(
1414
"//pkg/ccl",
1515
"//pkg/ccl/kvccl/kvtenantccl",
1616
"//pkg/ccl/partitionccl",
17+
"//pkg/clusterversion",
1718
"//pkg/config/zonepb",
1819
"//pkg/jobs/jobspb",
1920
"//pkg/roachpb",

pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/datadriven_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ import (
1717
"github.com/cockroachdb/cockroach/pkg/base"
1818
_ "github.com/cockroachdb/cockroach/pkg/ccl/kvccl/kvtenantccl"
1919
_ "github.com/cockroachdb/cockroach/pkg/ccl/partitionccl"
20+
"github.com/cockroachdb/cockroach/pkg/clusterversion"
2021
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
2122
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
2223
"github.com/cockroachdb/cockroach/pkg/roachpb"
24+
"github.com/cockroachdb/cockroach/pkg/server"
2325
"github.com/cockroachdb/cockroach/pkg/spanconfig"
2426
"github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator"
2527
"github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigtestutils"
@@ -116,12 +118,21 @@ func TestDataDriven(t *testing.T) {
116118
UseTransactionalDescIDGenerator: true,
117119
}
118120

121+
serverKnobs := &server.TestingKnobs{}
122+
if strings.Contains(path, "25_4_26_1_mixed_version") {
123+
serverKnobs = &server.TestingKnobs{
124+
DisableAutomaticVersionUpgrade: make(chan struct{}),
125+
ClusterVersionOverride: (clusterversion.V26_1_InstallMeta2StaticSplitPoint - 1).Version(),
126+
}
127+
}
128+
119129
tsArgs := func(attr string) base.TestServerArgs {
120130
return base.TestServerArgs{
121131
Knobs: base.TestingKnobs{
122132
GCJob: gcTestingKnobs,
123133
SpanConfig: scKnobs,
124134
SQLExecutor: sqlExecutorKnobs,
135+
Server: serverKnobs,
125136
UpgradeManager: &upgradebase.TestingKnobs{
126137
SkipHotRangesLoggerJobBootstrap: true,
127138
},
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
full-translate
2+
----
3+
/{Min-System/NodeLiveness} ttl_seconds=3600 num_replicas=5
4+
/System/NodeLiveness{-Max} ttl_seconds=600 num_replicas=5
5+
/System/{NodeLivenessMax-tsd} range system
6+
/System{/tsd-tse} range default
7+
/System{tse-/SystemSpanConfigKeys} range system
8+
/Table/{0-4} database system (host)
9+
/Table/{4-5} database system (host)
10+
/Table/{5-6} database system (host)
11+
/Table/{6-7} database system (host)
12+
/Table/{7-8} database system (host)
13+
/Table/{8-9} database system (host)
14+
/Table/{9-10} database system (host)
15+
/Table/1{1-2} ttl_seconds=600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true exclude_data_from_backup=true
16+
/Table/1{2-3} database system (host)
17+
/Table/1{3-4} database system (host)
18+
/Table/1{4-5} database system (host)
19+
/Table/1{5-6} database system (host)
20+
/Table/1{6-7} range system
21+
/Table/1{7-8} range system
22+
/Table/1{8-9} range system
23+
/Table/{19-20} database system (host)
24+
/Table/2{0-1} database system (host)
25+
/Table/2{1-2} database system (host)
26+
/Table/2{2-3} range system
27+
/Table/2{3-4} database system (host)
28+
/Table/2{4-5} database system (host)
29+
/Table/2{5-6} ttl_seconds=600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true exclude_data_from_backup=true
30+
/Table/2{6-7} database system (host)
31+
/Table/2{7-8} ttl_seconds=600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true exclude_data_from_backup=true
32+
/Table/2{8-9} database system (host)
33+
/{Table/29-NamespaceTable/30} range system
34+
/NamespaceTable/{30-Max} database system (host)
35+
/{NamespaceTable/Max-Table/32} database system (host)
36+
/Table/3{2-3} database system (host)
37+
/Table/3{3-4} database system (host)
38+
/Table/3{4-5} database system (host)
39+
/Table/3{5-6} database system (host)
40+
/Table/3{6-7} database system (host)
41+
/Table/3{7-8} database system (host)
42+
/Table/3{8-9} range system
43+
/Table/{39-40} database system (host)
44+
/Table/4{0-1} database system (host)
45+
/Table/4{1-2} database system (host)
46+
/Table/4{2-3} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
47+
/Table/4{3-4} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
48+
/Table/4{4-5} database system (host)
49+
/Table/4{5-6} ttl_seconds=7200 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true exclude_data_from_backup=true
50+
/Table/4{6-7} database system (host)
51+
/Table/4{7-8} ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true exclude_data_from_backup=true
52+
/Table/4{8-9} database system (host)
53+
/Table/5{0-1} database system (host)
54+
/Table/5{1-2} database system (host)
55+
/Table/5{2-3} database system (host)
56+
/Table/5{3-4} database system (host)
57+
/Table/5{4-5} database system (host)
58+
/Table/5{5-6} database system (host)
59+
/Table/5{6-7} database system (host)
60+
/Table/5{7-8} database system (host)
61+
/Table/5{8-9} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
62+
/Table/{59-60} database system (host)
63+
/Table/6{0-1} database system (host)
64+
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
65+
/Table/6{2-3} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
66+
/Table/6{3-4} database system (host)
67+
/Table/6{4-5} database system (host)
68+
/Table/6{5-6} database system (host)
69+
/Table/6{6-7} database system (host)
70+
/Table/6{7-8} database system (host)
71+
/Table/6{8-9} database system (host)
72+
/Table/{69-70} database system (host)
73+
/Table/7{0-1} database system (host)
74+
/Table/7{1-2} database system (host)
75+
/Table/7{2-3} database system (host)
76+
/Table/7{3-4} database system (host)
77+
/Table/7{4-5} database system (host)
78+
/Table/7{5-6} database system (host)
79+
/Table/7{6-7} database system (host)

pkg/clusterversion/cockroach_versions.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ const (
237237

238238
V26_1_Start
239239

240+
// V26_1_InstallMeta2StaticSplitPoint installs a static split point between
241+
// meta1 and meta2.
242+
V26_1_InstallMeta2StaticSplitPoint
243+
240244
// *************************************************
241245
// Step (1) Add new versions above this comment.
242246
// Do not add new versions to a patch release.
@@ -305,6 +309,8 @@ var versionTable = [numKeys]roachpb.Version{
305309
// v26.1 versions. Internal versions must be even.
306310
V26_1_Start: {Major: 25, Minor: 4, Internal: 2},
307311

312+
V26_1_InstallMeta2StaticSplitPoint: {Major: 25, Minor: 4, Internal: 4},
313+
308314
// *************************************************
309315
// Step (2): Add new versions above this comment.
310316
// Do not add new versions to a patch release.

pkg/spanconfig/spanconfigsqltranslator/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/spanconfig/spanconfigsqltranslator",
77
visibility = ["//visibility:public"],
88
deps = [
9+
"//pkg/clusterversion",
910
"//pkg/config/zonepb",
1011
"//pkg/keys",
1112
"//pkg/kv",

pkg/spanconfig/spanconfigsqltranslator/sqltranslator.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ package spanconfigsqltranslator
1111
import (
1212
"context"
1313

14+
"github.com/cockroachdb/cockroach/pkg/clusterversion"
1415
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
1516
"github.com/cockroachdb/cockroach/pkg/keys"
1617
"github.com/cockroachdb/cockroach/pkg/kv"
@@ -257,14 +258,18 @@ func (s *SQLTranslator) generateSpanConfigurationsForNamedZone(
257258
switch name {
258259
case zonepb.DefaultZoneName: // nothing to do.
259260
case zonepb.MetaZoneName:
260-
// TODO(ibrahim): version gate this to 26.1
261-
// Meta1 is not allowed to split, whereas meta2 is. We always install a
262-
// split point at the start of meta2 to ensure load based splitting can
263-
// apply to meta2. See
264-
// https://github.com/cockroachdb/cockroach/issues/119421.
265-
spans = append(spans, keys.Meta1Span)
266-
spans = append(spans, roachpb.Span{Key: keys.Meta2Prefix, EndKey: keys.NodeLivenessSpan.Key})
267-
261+
// TODO(ibrahim): Once this version gate goes away, we do no longer need to
262+
// thread in cluster.Settings into the SQLTranslator.
263+
if s.settings.Version.IsActive(ctx, clusterversion.V26_1_InstallMeta2StaticSplitPoint) {
264+
// Meta1 is not allowed to split, whereas meta2 is. We always install a
265+
// split point at the start of meta2 to ensure load based splitting can
266+
// apply to meta2. See
267+
// https://github.com/cockroachdb/cockroach/issues/119421.
268+
spans = append(spans, keys.Meta1Span)
269+
spans = append(spans, roachpb.Span{Key: keys.Meta2Prefix, EndKey: keys.NodeLivenessSpan.Key})
270+
} else {
271+
spans = append(spans, roachpb.Span{Key: keys.Meta1Span.Key, EndKey: keys.NodeLivenessSpan.Key})
272+
}
268273
case zonepb.LivenessZoneName:
269274
spans = append(spans, keys.NodeLivenessSpan)
270275
case zonepb.TimeseriesZoneName:

0 commit comments

Comments
 (0)