Skip to content

Commit

Permalink
spanconfig: carve empty ranges for pseudo-table IDs
Browse files Browse the repository at this point in the history
This commit is similar in spirit to cockroachdb#73746 in that it gets rid of a
benign difference between the span configs infrastructure and the system
config span. Whe nnabling span configs by default (cockroachdb#73876), we observed
a wide blast radius with respect to test failures. This was in large
part due to assumptions we've baked in regarding the number of splits we
should expect at cluster start, often waiting for the same number of
ranges to form before executing the rest of the test.

The differences between the SystemConfigSpan and the span configs
infrastructure in how they handled (empty) pseudo table keyspaces makes
for an annoying large list of tests to adjust manually. Instead we take
the lazy route and generate empty ranges for pseudo table IDs as we did
before. We can get rid of this special handling once we actually get rid
of the system config span, and adjust all these tests accordingly. Doing
it later is also preferable should we need to revert pieces of cockroachdb#73876
due to unforeseen instability.

Release note: None
  • Loading branch information
irfansharif committed Jan 4, 2022
1 parent e5eda9f commit e6925ae
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ func TestDataDriven(t *testing.T) {
Context: 2,
})
require.NoError(t, err)
if diff == "" {
return ""
}

lines := strings.Split(strings.TrimSpace(diff), "\n")
headerLines, diffLines := lines[:2], lines[2:]
Expand Down
46 changes: 7 additions & 39 deletions pkg/ccl/spanconfigccl/spanconfigcomparedccl/testdata/basic
Original file line number Diff line number Diff line change
Expand Up @@ -37,47 +37,9 @@ configs version=current offset=4 limit=3
/Table/11 range system
...

# The gossiped system config span splits (needlessly) on pseudo table IDs; the
# new subsystem doesn't.
#
# MetaRangesID = 16 // pseudo
# SystemRangesID = 17 // pseudo
# TimeseriesRangesID = 18 // pseudo
# LivenessRangesID = 22 // pseudo
# PublicSchemaID = 29 // pseudo
# TenantsRangesID = 38 // pseudo

diff offset=2 limit=21
----
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
/Table/15 range system
-/Table/16 range system
-/Table/17 range system
-/Table/18 range system
/Table/19 range system
/Table/20 range system
/Table/21 range system
-/Table/22 range system
/Table/23 range system
/Table/24 range system
@@ -23,5 +19,4 @@
/Table/27 ttl_seconds=600 num_replicas=5
/Table/28 range system
-/Table/29 range system
/NamespaceTable/30 range system
/NamespaceTable/Max range system
@@ -32,5 +27,4 @@
/Table/36 range system
/Table/37 range system
-/Table/38 range system
/Table/39 range system
...

# Both subsystems observe splits for the tables created above.

configs version=current offset=35
configs version=current offset=41
----
...
/Table/46 range system
Expand All @@ -93,4 +55,10 @@ configs version=legacy offset=41
/Table/56 num_replicas=7 num_voters=5
/Table/57 num_replicas=7

# Both subsystems are identical with respect to exposed configs (including for
# pseudo table IDs).

diff
----

# vim:ft=diff
23 changes: 9 additions & 14 deletions pkg/ccl/spanconfigccl/spanconfigcomparedccl/testdata/multitenant
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,23 @@ initialize tenant=11
----

# Before kicking starting off tenant reconciliation, we should find seed
# configs for the newly initialized tenants. As yet, there are no (additional)
# differences between the subsystems.
configs version=current offset=37
# configs for the newly initialized tenants. As yet, there are no differences
# between the subsystems.
configs version=current offset=43
----
...
/Tenant/10 range default
/Tenant/11 range default

diff offset=24
diff
----
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...

reconcile tenant=11
----

# As soon as tenant-11 starts reconciling, we should observe more fine-grained
# span configs within its keyspan. This isn't true for the legacy system.
configs version=current offset=37 limit=5
configs version=current offset=43 limit=5
----
...
/Tenant/10 range default
Expand All @@ -47,12 +44,11 @@ configs version=legacy offset=43
/Tenant/10 range default
/Tenant/11 range default

diff offset=24 limit=10
diff limit=10
----
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
@@ -44,3 +38,36 @@
@@ -44,3 +44,36 @@
/Tenant/10 range default
/Tenant/11 range default
+/Tenant/11/Table/4 range default
Expand All @@ -73,12 +69,11 @@ CREATE TABLE db.t2();
ALTER TABLE db.t1 CONFIGURE ZONE using num_replicas = 42, gc.ttlseconds = 1000;
----

diff offset=24
diff
----
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
@@ -44,3 +38,38 @@
@@ -44,3 +44,38 @@
/Tenant/10 range default
/Tenant/11 range default
+/Tenant/11/Table/4 range default
Expand Down
28 changes: 26 additions & 2 deletions pkg/ccl/spanconfigccl/spanconfigreconcilerccl/testdata/basic
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ upsert /Table/1{2-3} range system
upsert /Table/1{3-4} range system
upsert /Table/1{4-5} range system
upsert /Table/1{5-6} range system
upsert /Table/1{6-7} range system
upsert /Table/1{7-8} range system
upsert /Table/1{8-9} range system
upsert /Table/{19-20} range system
upsert /Table/2{0-1} range system
upsert /Table/2{1-2} range system
upsert /Table/2{2-3} range system
upsert /Table/2{3-4} range system
upsert /Table/2{4-5} range system
upsert /Table/2{5-6} ttl_seconds=600 num_replicas=5
upsert /Table/2{6-7} range system
upsert /Table/2{7-8} ttl_seconds=600 num_replicas=5
upsert /Table/2{8-9} range system
upsert /{Table/29-NamespaceTable/30} range system
upsert /NamespaceTable/{30-Max} range system
upsert /{NamespaceTable/Max-Table/32} range system
upsert /Table/3{2-3} range system
Expand All @@ -39,6 +44,7 @@ upsert /Table/3{4-5} range system
upsert /Table/3{5-6} range system
upsert /Table/3{6-7} range system
upsert /Table/3{7-8} range system
upsert /Table/3{8-9} range system
upsert /Table/{39-40} range system
upsert /Table/4{0-1} range system
upsert /Table/4{1-2} range system
Expand Down Expand Up @@ -74,7 +80,7 @@ upsert /Table/5{6-7} num_replicas=7 num_voters=5
delete /Table/5{7-8}
upsert /Table/5{7-8} num_replicas=7

state offset=41
state offset=47
----
...
/Table/5{6-7} num_replicas=7 num_voters=5
Expand Down Expand Up @@ -106,12 +112,20 @@ delete /Table/1{4-5}
upsert /Table/1{4-5} ttl_seconds=100 num_replicas=5
delete /Table/1{5-6}
upsert /Table/1{5-6} ttl_seconds=100 num_replicas=5
delete /Table/1{6-7}
upsert /Table/1{6-7} ttl_seconds=100 num_replicas=5
delete /Table/1{7-8}
upsert /Table/1{7-8} ttl_seconds=100 num_replicas=5
delete /Table/1{8-9}
upsert /Table/1{8-9} ttl_seconds=100 num_replicas=5
delete /Table/{19-20}
upsert /Table/{19-20} ttl_seconds=100 num_replicas=5
delete /Table/2{0-1}
upsert /Table/2{0-1} ttl_seconds=100 num_replicas=5
delete /Table/2{1-2}
upsert /Table/2{1-2} ttl_seconds=100 num_replicas=5
delete /Table/2{2-3}
upsert /Table/2{2-3} ttl_seconds=100 num_replicas=5
delete /Table/2{3-4}
upsert /Table/2{3-4} ttl_seconds=100 num_replicas=5
delete /Table/2{4-5}
Expand All @@ -120,6 +134,8 @@ delete /Table/2{6-7}
upsert /Table/2{6-7} ttl_seconds=100 num_replicas=5
delete /Table/2{8-9}
upsert /Table/2{8-9} ttl_seconds=100 num_replicas=5
delete /{Table/29-NamespaceTable/30}
upsert /{Table/29-NamespaceTable/30} ttl_seconds=100 num_replicas=5
delete /NamespaceTable/{30-Max}
upsert /NamespaceTable/{30-Max} ttl_seconds=100 num_replicas=5
delete /{NamespaceTable/Max-Table/32}
Expand All @@ -136,6 +152,8 @@ delete /Table/3{6-7}
upsert /Table/3{6-7} ttl_seconds=100 num_replicas=5
delete /Table/3{7-8}
upsert /Table/3{7-8} ttl_seconds=100 num_replicas=5
delete /Table/3{8-9}
upsert /Table/3{8-9} ttl_seconds=100 num_replicas=5
delete /Table/{39-40}
upsert /Table/{39-40} ttl_seconds=100 num_replicas=5
delete /Table/4{0-1}
Expand All @@ -153,7 +171,7 @@ upsert /Table/4{6-7} ttl_seconds=100 num_replicas=5
delete /Table/4{7-8}
upsert /Table/4{7-8} ttl_seconds=100 num_replicas=5

state offset=5 limit=36
state offset=5 limit=42
----
...
/Table/{SystemConfigSpan/Start-4} ttl_seconds=100 num_replicas=5
Expand All @@ -166,15 +184,20 @@ state offset=5 limit=36
/Table/1{3-4} ttl_seconds=100 num_replicas=5
/Table/1{4-5} ttl_seconds=100 num_replicas=5
/Table/1{5-6} ttl_seconds=100 num_replicas=5
/Table/1{6-7} ttl_seconds=100 num_replicas=5
/Table/1{7-8} ttl_seconds=100 num_replicas=5
/Table/1{8-9} ttl_seconds=100 num_replicas=5
/Table/{19-20} ttl_seconds=100 num_replicas=5
/Table/2{0-1} ttl_seconds=100 num_replicas=5
/Table/2{1-2} ttl_seconds=100 num_replicas=5
/Table/2{2-3} ttl_seconds=100 num_replicas=5
/Table/2{3-4} ttl_seconds=100 num_replicas=5
/Table/2{4-5} ttl_seconds=100 num_replicas=5
/Table/2{5-6} ttl_seconds=600 num_replicas=5
/Table/2{6-7} ttl_seconds=100 num_replicas=5
/Table/2{7-8} ttl_seconds=600 num_replicas=5
/Table/2{8-9} ttl_seconds=100 num_replicas=5
/{Table/29-NamespaceTable/30} ttl_seconds=100 num_replicas=5
/NamespaceTable/{30-Max} ttl_seconds=100 num_replicas=5
/{NamespaceTable/Max-Table/32} ttl_seconds=100 num_replicas=5
/Table/3{2-3} ttl_seconds=100 num_replicas=5
Expand All @@ -183,6 +206,7 @@ state offset=5 limit=36
/Table/3{5-6} ttl_seconds=100 num_replicas=5
/Table/3{6-7} ttl_seconds=100 num_replicas=5
/Table/3{7-8} ttl_seconds=100 num_replicas=5
/Table/3{8-9} ttl_seconds=100 num_replicas=5
/Table/{39-40} ttl_seconds=100 num_replicas=5
/Table/4{0-1} ttl_seconds=100 num_replicas=5
/Table/4{1-2} ttl_seconds=100 num_replicas=5
Expand Down
10 changes: 5 additions & 5 deletions pkg/ccl/spanconfigccl/spanconfigreconcilerccl/testdata/indexes
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mutations
----
upsert /Table/5{6-7} range default

state offset=41
state offset=47
----
...
/Table/5{6-7} range default
Expand All @@ -39,7 +39,7 @@ upsert /Table/56{-/2} num_replicas=7
upsert /Table/56/{2-3} num_replicas=7 num_voters=5
upsert /Table/5{6/3-7} num_replicas=7

state offset=41
state offset=47
----
...
/Table/56{-/2} num_replicas=7
Expand All @@ -62,7 +62,7 @@ upsert /Table/56/{2-3} ttl_seconds=25 num_replicas=7 num_vot
delete /Table/5{6/3-7}
upsert /Table/5{6/3-7} ttl_seconds=3600 num_replicas=7

state offset=41
state offset=47
----
...
/Table/56{-/2} ttl_seconds=3600 num_replicas=7
Expand All @@ -75,7 +75,7 @@ exec-sql
ALTER TABLE db.t CONFIGURE ZONE USING num_replicas = 9
----

state offset=41
state offset=47
----
...
/Table/56{-/2} ttl_seconds=3600 num_replicas=9
Expand All @@ -101,7 +101,7 @@ delete /Table/56{-/2}
delete /Table/56/{2-3}
delete /Table/5{6/3-7}

state offset=40
state offset=46
----
...
/Table/4{7-8} range system
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mutations

# We should observe placeholder entries for both tenants (installed when
# creating tenant records).
state offset=41
state offset=47
----
...
/Tenant/10{-"\x00"} range default
Expand Down Expand Up @@ -67,7 +67,7 @@ upsert /Tenant/10/Table/4{3-4} range default
upsert /Tenant/10/Table/4{4-5} range default
upsert /Tenant/10/Table/4{6-7} range default

state offset=41
state offset=47
----
...
/Tenant/10{-/Table/4} range default
Expand Down Expand Up @@ -117,7 +117,7 @@ mutations tenant=10
upsert /Tenant/10/Table/5{6-7} range default
upsert /Tenant/10/Table/5{7-8} range default

state offset=75
state offset=81
----
...
/Tenant/10/Table/5{6-7} range default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ state limit=5
/System{tse-/Max} ttl_seconds=50
...

state offset=40
state offset=46
----
...
/Table/4{7-8} range system
Expand All @@ -135,7 +135,7 @@ mutations
----
upsert /Table/5{7-8} ttl_seconds=50

state offset=40
state offset=46
----
...
/Table/4{7-8} range system
Expand Down
Loading

0 comments on commit e6925ae

Please sign in to comment.