Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-23.1.0: sql: avoid tenant ID reuse #101847

Merged
merged 4 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,4 @@ trace.opentelemetry.collector string address of an OpenTelemetry trace collecto
trace.snapshot.rate duration 0s if non-zero, interval at which background trace snapshots are captured
trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https://<ui>/#/debug/tracez
trace.zipkin.collector string the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.
version version 22.2-98 set the active cluster version in the format '<major>.<minor>'
version version 22.2-100 set the active cluster version in the format '<major>.<minor>'
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,6 @@
<tr><td><div id="setting-trace-snapshot-rate" class="anchored"><code>trace.snapshot.rate</code></div></td><td>duration</td><td><code>0s</code></td><td>if non-zero, interval at which background trace snapshots are captured</td></tr>
<tr><td><div id="setting-trace-span-registry-enabled" class="anchored"><code>trace.span_registry.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if set, ongoing traces can be seen at https://&lt;ui&gt;/#/debug/tracez</td></tr>
<tr><td><div id="setting-trace-zipkin-collector" class="anchored"><code>trace.zipkin.collector</code></div></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as &lt;host&gt;:&lt;port&gt;. If no port is specified, 9411 will be used.</td></tr>
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>22.2-98</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td></tr>
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>22.2-100</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td></tr>
</tbody>
</table>
23 changes: 21 additions & 2 deletions pkg/ccl/backupccl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6845,7 +6845,13 @@ func TestBackupRestoreTenant(t *testing.T) {
defer log.Scope(t).Close(t)

params := base.TestClusterArgs{ServerArgs: base.TestServerArgs{
Knobs: base.TestingKnobs{JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals()},
Knobs: base.TestingKnobs{
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
TenantTestingKnobs: &sql.TenantTestingKnobs{
// The tests expect specific tenant IDs to show up.
EnableTenantIDReuse: true,
},
},

// Disabled to probabilistically spin up a tenant in each server because the
// test explicitly sets up tenants to test on.
Expand Down Expand Up @@ -7158,6 +7164,13 @@ func TestBackupRestoreTenant(t *testing.T) {
// system.tenants table. Disable the default test tenant because
// it's not necessary.
DisableDefaultTestTenant: true,
Knobs: base.TestingKnobs{
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
TenantTestingKnobs: &sql.TenantTestingKnobs{
// This test expects a specific tenant ID to be selected after DROP TENANT.
EnableTenantIDReuse: true,
},
},
}},
)

Expand Down Expand Up @@ -9577,7 +9590,13 @@ func TestProtectRestoreTargets(t *testing.T) {
numAccounts := 100
params := base.TestClusterArgs{
ServerArgs: base.TestServerArgs{
Knobs: base.TestingKnobs{JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals()},
Knobs: base.TestingKnobs{
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
TenantTestingKnobs: &sql.TenantTestingKnobs{
// The tests expect specific tenant IDs to show up.
EnableTenantIDReuse: true,
},
},
},
}
tc, sqlDB, tempDir, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode,
Expand Down
5 changes: 5 additions & 0 deletions pkg/ccl/backupccl/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ func (d *datadrivenTestState) addCluster(t *testing.T, cfg clusterCfg) error {
params.ServerArgs.DisableDefaultTestTenant = cfg.disableTenant
params.ServerArgs.Knobs = base.TestingKnobs{
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
TenantTestingKnobs: &sql.TenantTestingKnobs{
// The tests in this package are particular about the tenant IDs
// they get in CREATE TENANT.
EnableTenantIDReuse: true,
},
}

settings := cluster.MakeTestingClusterSettings()
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/backupccl/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,7 @@ func createImportingDescriptors(
&tenantInfoCopy,
initialTenantZoneConfig,
false, /* ifNotExists */
p.ExecCfg().TenantTestingKnobs,
); err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/ccl/backupccl/system_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,9 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{
systemschema.DescIDSequence.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
systemschema.TenantIDSequence.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
systemschema.SystemJobInfoTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ txn_id txn_fingerprint_id query implicit_txn session_id start_time end_tim
query ITTI
SELECT range_id, start_pretty, end_pretty, lease_holder FROM crdb_internal.ranges
----
63 /Tenant/10 /Tenant/11 1
64 /Tenant/10 /Tenant/11 1

query ITT
SELECT range_id, start_pretty, end_pretty FROM crdb_internal.ranges_no_leases
----
63 /Tenant/10 /Tenant/11
64 /Tenant/10 /Tenant/11

query IT
SELECT zone_id, target FROM crdb_internal.zones ORDER BY 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ skipif config multiregion-9node-3region-3azs-vec-off
query I retry
SELECT DISTINCT range_id FROM [SHOW RANGES FROM TABLE messages_rbr]
----
65
66

# Update does not fail when accessing all rows in messages_rbr because lookup
# join does not error out the lookup table in phase 1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ ap-southeast-2 23
query TT
SELECT start_key, end_key FROM [SHOW RANGE FROM TABLE regional_by_row_table FOR ROW ('ap-southeast-2', 1)]
----
<before:/Table/61> …
<before:/Table/62> …

query TIIII
SELECT crdb_region, pk, pk2, a, b FROM regional_by_row_table
Expand Down Expand Up @@ -406,7 +406,7 @@ SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM INDEX r
ORDER BY 1
----
start_key end_key replicas lease_holder
<before:/Table/61> …/"\x80"/0 {1} 1
<before:/Table/62> …/"\x80"/0 {1} 1
…/"\x80"/0 …/"\xc0"/0 {4} 4
…/"\xc0"/0 <after:/Table/110/5> {7} 7

Expand Down
4 changes: 4 additions & 0 deletions pkg/ccl/spanconfigccl/spanconfigreconcilerccl/testdata/basic
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ upsert /Table/5{8-9} database system (host)
upsert /Table/{59-60} database system (host)
upsert /Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
upsert /Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
upsert /Table/6{2-3} database system (host)

exec-sql
CREATE DATABASE db;
Expand Down Expand Up @@ -118,6 +119,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Table/10{6-7} num_replicas=7 num_voters=5
/Table/10{7-8} num_replicas=7
/Table/11{2-3} num_replicas=7
Expand Down Expand Up @@ -225,6 +227,8 @@ delete /Table/5{8-9}
upsert /Table/5{8-9} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
delete /Table/{59-60}
upsert /Table/{59-60} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
delete /Table/6{2-3}
upsert /Table/6{2-3} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true

state offset=5 limit=42
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Table/10{6-7} range default

exec-sql
Expand Down Expand Up @@ -70,6 +71,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Table/106{-/2} num_replicas=7
/Table/106/{2-3} num_replicas=7 num_voters=5
/Table/10{6/3-7} num_replicas=7
Expand Down Expand Up @@ -107,6 +109,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Table/106{-/2} ttl_seconds=3600 num_replicas=7
/Table/106/{2-3} ttl_seconds=25 num_replicas=7 num_voters=5
/Table/10{6/3-7} ttl_seconds=3600 num_replicas=7
Expand Down Expand Up @@ -134,6 +137,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Table/106{-/2} ttl_seconds=3600 num_replicas=9
/Table/106/{2-3} ttl_seconds=25 num_replicas=9 num_voters=5
/Table/10{6/3-7} ttl_seconds=3600 num_replicas=9
Expand Down Expand Up @@ -175,3 +179,4 @@ state offset=46
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Tenant/10{-\x00} database system (tenant)
/Tenant/11{-\x00} database system (tenant)
/Tenant/12{-\x00} database system (tenant)
Expand Down Expand Up @@ -110,6 +111,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Tenant/10{-/Table/4} database system (tenant)
/Tenant/10/Table/{4-5} database system (tenant)
/Tenant/10/Table/{5-6} database system (tenant)
Expand Down Expand Up @@ -179,6 +181,7 @@ upsert /Tenant/10/Table/11{3-4} range default
state offset=81
----
...
/Tenant/10/NamespaceTable/{30-Max} database system (tenant)
/Tenant/10/{NamespaceTable/Max-Table/32} database system (tenant)
/Tenant/10/Table/3{2-3} database system (tenant)
/Tenant/10/Table/3{3-4} database system (tenant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Tenant/10{-\x00} database system (tenant)
/Tenant/11{-\x00} database system (tenant)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Tenant/10{-\x00} database system (tenant)
/Tenant/11{-\x00} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
/Tenant/12{-\x00} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
Expand Down Expand Up @@ -82,6 +83,7 @@ state offset=47
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Tenant/10{-/Table/4} database system (tenant)
/Tenant/10/Table/{4-5} database system (tenant)
/Tenant/10/Table/{5-6} database system (tenant)
Expand Down Expand Up @@ -164,6 +166,7 @@ mutations discard tenant=11
state offset=81
----
...
/Tenant/10/NamespaceTable/{30-Max} database system (tenant)
/Tenant/10/{NamespaceTable/Max-Table/32} database system (tenant)
/Tenant/10/Table/3{2-3} database system (tenant)
/Tenant/10/Table/3{3-4} database system (tenant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ state offset=59
...
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Tenant/11{-\x00} database system (tenant)
/Tenant/12{-\x00} database system (tenant)

Expand All @@ -37,8 +38,8 @@ state offset=60 limit=3
----
...
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Tenant/11{-/Table/4} database system (tenant)
/Tenant/11/Table/{4-5} database system (tenant)
...

# Peek near the end of the span_configurations table where tenant=11's records
Expand All @@ -47,6 +48,7 @@ state offset=60 limit=3
state offset=103
----
...
/Tenant/11/Table/5{6-7} database system (tenant)
/Tenant/11/Table/5{7-8} database system (tenant)
/Tenant/11/Table/5{8-9} database system (tenant)
/Tenant/11/Table/{59-60} database system (tenant)
Expand Down Expand Up @@ -117,7 +119,7 @@ state offset=59 limit=5
...
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Tenant/10{-\x00} database system (tenant)
/Tenant/11{-/Table/4} database system (tenant)
/Tenant/11/Table/{4-5} database system (tenant)
...
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ state offset=46
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Table/10{6-7} ttl_seconds=50

# Make sure future descendants observe the same.
Expand Down Expand Up @@ -167,6 +168,7 @@ state offset=46
/Table/{59-60} database system (host)
/Table/6{0-1} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{1-2} ttl_seconds=3600 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
/Table/6{2-3} database system (host)
/Table/10{6-7} ttl_seconds=50
/Table/10{7-8} ttl_seconds=50

Expand Down
Loading