-
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.
spanconfigsql{watcher,reconciler}: setup SQLWatcher to watch for pts …
…updates This change sets up a rangefeed on the `system.pts_records` table, and adds this to the set of rangefeeds managed by the SQLWatcher. We switch the unit emitted by the SQLWatcher to a union type called `SQLUpdate` which captures either an update to a descriptor or to a protected timestamp target. The zones and descriptor table rangefeeds will continue to emit descriptor updates. The pts rangefeed will emit descriptor updates for records that target schema objects, and pts target updates for records that target cluster or tenants. The SQLWatcher continues to dedup the SQLUpdates that it emits, so as to ensure there is only one SQLUpdate per descriptor ID, and one SQLUpdate per cluster or tenant target. The reconciler registers a handler that is invoked everytime a batch of SQLUpdates are emitted by the SQLWatcher. There is change in semantics in this part of the code, a future PR will teach the reconciler to parse the pts target SQLUpdates, and in turn instruct the SQLTranslator to generate the appropriate `SystemSpanConfigs`. Note, this file moves the sqlwatcher tests into a ccl package so as to be able to run backup statements to test the rangefeed on the pts table. Informs: #73727 Release note: None
- Loading branch information
1 parent
c4f15d6
commit e0ce909
Showing
10 changed files
with
651 additions
and
139 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_test") | ||
|
||
go_test( | ||
name = "spanconfigsqlwatcherccl_test", | ||
srcs = [ | ||
"main_test.go", | ||
"sqlwatcher_test.go", | ||
], | ||
deps = [ | ||
"//pkg/base", | ||
"//pkg/ccl/backupccl", | ||
"//pkg/ccl/kvccl/kvtenantccl", | ||
"//pkg/ccl/storageccl", | ||
"//pkg/ccl/utilccl", | ||
"//pkg/cloud/impl:cloudimpl", | ||
"//pkg/jobs", | ||
"//pkg/keys", | ||
"//pkg/kv/kvclient/rangefeed:with-mocks", | ||
"//pkg/kv/kvserver/protectedts", | ||
"//pkg/roachpb:with-mocks", | ||
"//pkg/security", | ||
"//pkg/security/securitytest", | ||
"//pkg/server", | ||
"//pkg/spanconfig", | ||
"//pkg/spanconfig/spanconfigsqlwatcher", | ||
"//pkg/sql/catalog/descpb", | ||
"//pkg/testutils", | ||
"//pkg/testutils/serverutils", | ||
"//pkg/testutils/sqlutils", | ||
"//pkg/testutils/testcluster", | ||
"//pkg/util/hlc", | ||
"//pkg/util/leaktest", | ||
"//pkg/util/randutil", | ||
"//pkg/util/syncutil", | ||
"@com_github_cockroachdb_errors//:errors", | ||
"@com_github_stretchr_testify//require", | ||
], | ||
) |
34 changes: 34 additions & 0 deletions
34
pkg/ccl/spanconfigccl/spanconfigsqlwatcherccl/main_test.go
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,34 @@ | ||
// Copyright 2016 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package spanconfigsqlwatcherccl | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
_ "github.com/cockroachdb/cockroach/pkg/ccl/storageccl" | ||
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl" | ||
"github.com/cockroachdb/cockroach/pkg/security" | ||
"github.com/cockroachdb/cockroach/pkg/security/securitytest" | ||
"github.com/cockroachdb/cockroach/pkg/server" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster" | ||
"github.com/cockroachdb/cockroach/pkg/util/randutil" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
defer utilccl.TestingEnableEnterprise()() | ||
security.SetAssetLoader(securitytest.EmbeddedAssets) | ||
randutil.SeedForTests() | ||
serverutils.InitTestServerFactory(server.TestServerFactory) | ||
serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) | ||
os.Exit(m.Run()) | ||
} | ||
|
||
//go:generate ../../../util/leaktest/add-leaktest.sh *_test.go |
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
Oops, something went wrong.