-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spanconfigreconciler{ccl}: apply system span config diffs to the store
This change teaches the reconciler about system span configs. Concretely, we make the following changes: - A full reconciliation when checking for existing span configurations now asks for SpanConfigs corresponding to the SystemTargets relevant to the tenant. For the host tenant this includes the SystemTarget for the `entire-keyspace` as well as the SystemTarget for span configs installed by the host tenant on its tenant keyspace, and on other secondary tenant keyspaces. For secondary tenants this only includes the SystemTarget for span configs installed by it on its own tenant keyspace. - During incremental reconciliation, before applying our updates to the Store, we now also check for "missing protected timestamp system targets". These correspond to protected timestamp records that target a `Cluster` or a `Tenant` but no longer exist in the system.protected_ts_records table as they have been released by the client. For every such unique missing system target we apply a spanconfig.Deletion to the Store. In order to make the above possible, this change moves the ptsStateReader from the `spanconfigsqltranslator` package, to the top level `spanconfig` package. Informs: #73727 Release note: None
- Loading branch information
1 parent
ad0cdd0
commit 8b7d2e5
Showing
18 changed files
with
596 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
pkg/ccl/spanconfigccl/spanconfigreconcilerccl/testdata/multitenant/protectedts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# Test span configs in the presence of multiple secondary tenants, each running | ||
# their own reconciliation loop. | ||
|
||
reconcile | ||
---- | ||
|
||
mutations discard | ||
---- | ||
|
||
initialize tenant=10 | ||
---- | ||
|
||
# Ensure that the host tenant observes no mutations. | ||
mutations | ||
---- | ||
|
||
# We should observe placeholder entries for both tenants (installed when | ||
# creating tenant records). | ||
state offset=47 | ||
---- | ||
... | ||
/Table/5{0-1} database system (host) | ||
/Tenant/10{-"\x00"} database system (tenant) | ||
|
||
# Write a protected timestamp record on the system tenant cluster. | ||
protect record-id=1 ts=1 | ||
cluster | ||
---- | ||
|
||
# Write a protected timestamp record on the system tenant keyspace, and on the | ||
# secondary tenant keyspace. | ||
protect record-id=2 ts=2 | ||
tenants 1,10 | ||
---- | ||
|
||
# Start the reconciliation loop for the secondary tenant. | ||
reconcile tenant=10 | ||
---- | ||
|
||
# We should see protected timestamp record mutations as the host tenant. | ||
mutations | ||
---- | ||
upsert {entire-keyspace} pts=[1] | ||
upsert {source=1,target=1} pts=[2] | ||
upsert {source=1,target=10} pts=[2] | ||
|
||
# We shouldn't see any protected timestamp record mutations as a secondary | ||
# tenant. | ||
mutations tenant=10 | ||
---- | ||
delete /Tenant/10{-"\x00"} | ||
upsert /Tenant/10{-/Table/4} database system (tenant) | ||
upsert /Tenant/10/Table/{4-5} database system (tenant) | ||
upsert /Tenant/10/Table/{5-6} database system (tenant) | ||
upsert /Tenant/10/Table/{6-7} database system (tenant) | ||
upsert /Tenant/10/Table/{7-8} database system (tenant) | ||
upsert /Tenant/10/Table/1{1-2} database system (tenant) | ||
upsert /Tenant/10/Table/1{2-3} database system (tenant) | ||
upsert /Tenant/10/Table/1{3-4} database system (tenant) | ||
upsert /Tenant/10/Table/1{4-5} database system (tenant) | ||
upsert /Tenant/10/Table/1{5-6} database system (tenant) | ||
upsert /Tenant/10/Table/{19-20} database system (tenant) | ||
upsert /Tenant/10/Table/2{0-1} database system (tenant) | ||
upsert /Tenant/10/Table/2{1-2} database system (tenant) | ||
upsert /Tenant/10/Table/2{3-4} database system (tenant) | ||
upsert /Tenant/10/Table/2{4-5} database system (tenant) | ||
upsert /Tenant/10/Table/2{5-6} database system (tenant) | ||
upsert /Tenant/10/Table/2{6-7} database system (tenant) | ||
upsert /Tenant/10/Table/2{7-8} database system (tenant) | ||
upsert /Tenant/10/Table/2{8-9} database system (tenant) | ||
upsert /Tenant/10/NamespaceTable/{30-Max} database system (tenant) | ||
upsert /Tenant/10/{NamespaceTable/Max-Table/32} database system (tenant) | ||
upsert /Tenant/10/Table/3{2-3} database system (tenant) | ||
upsert /Tenant/10/Table/3{3-4} database system (tenant) | ||
upsert /Tenant/10/Table/3{4-5} database system (tenant) | ||
upsert /Tenant/10/Table/3{5-6} database system (tenant) | ||
upsert /Tenant/10/Table/3{6-7} database system (tenant) | ||
upsert /Tenant/10/Table/3{7-8} database system (tenant) | ||
upsert /Tenant/10/Table/{39-40} database system (tenant) | ||
upsert /Tenant/10/Table/4{0-1} database system (tenant) | ||
upsert /Tenant/10/Table/4{1-2} database system (tenant) | ||
upsert /Tenant/10/Table/4{2-3} database system (tenant) | ||
upsert /Tenant/10/Table/4{3-4} database system (tenant) | ||
upsert /Tenant/10/Table/4{4-5} database system (tenant) | ||
upsert /Tenant/10/Table/4{6-7} database system (tenant) | ||
|
||
exec-sql tenant=10 | ||
CREATE DATABASE db; | ||
CREATE TABLE db.t1(); | ||
CREATE TABLE db.t2(); | ||
---- | ||
|
||
# Write a protected timestamp record on the cluster as a secondary tenant. | ||
protect record-id=3 ts=3 cluster tenant=10 | ||
cluster | ||
---- | ||
|
||
# We expect to see no mutations on the host tenant. | ||
mutations | ||
---- | ||
|
||
mutations tenant=10 | ||
---- | ||
upsert {source=10,target=10} pts=[3] | ||
upsert /Tenant/10/Table/10{6-7} range default | ||
upsert /Tenant/10/Table/10{7-8} range default | ||
|
||
state limit=4 | ||
---- | ||
{entire-keyspace} pts=[1] | ||
{source=1,target=1} pts=[2] | ||
{source=1,target=10} pts=[2] | ||
{source=10,target=10} pts=[3] | ||
... | ||
|
||
# Release all the protected timestamp records from the host tenant. | ||
release record-id=1 | ||
---- | ||
|
||
release record-id=2 | ||
---- | ||
|
||
# We expect to see no mutations on the secondary tenant. | ||
mutations tenant=10 | ||
---- | ||
|
||
mutations | ||
---- | ||
delete {entire-keyspace} | ||
delete {source=1,target=1} | ||
delete {source=1,target=10} | ||
|
||
# Release all the protected timestamp records from the secondary tenant. | ||
release record-id=3 tenant=10 | ||
---- | ||
|
||
mutations tenant=10 | ||
---- | ||
delete {source=10,target=10} | ||
|
||
# All system span config targets should have been removed at this point. | ||
state limit=4 | ||
---- | ||
/{Min-System/NodeLiveness} ttl_seconds=3600 num_replicas=5 | ||
/System/NodeLiveness{-Max} ttl_seconds=600 num_replicas=5 | ||
/System/{NodeLivenessMax-tsd} range system | ||
/System{/tsd-tse} range default | ||
... |
Oops, something went wrong.