forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spanconfig: introduce the span config manager
This patch introduces the spanconfigmanager.Manager. This struct is responsible for providing a hook to idempootently set up an auto span config reconciliation job which is responsible for reconciling SQL zone configs to KV span configs. This job is intended to be a per tenant singleton job that is non-cancellable. The hook the manager exposes ensures these semantics. Every SQL pod on startup creates a background task that periodically calls into this hook. We don't expect these calls to actually be instantiating a job after the first SQL pod has won the race, yet we do this periodic thing in the case that there has been an error in the job that has transitioned it to the failed state. The interval at which this happens is controlled by the `sql.span_config_reconciliation_job.idempotent_start_interval` cluster setting. It defaults to 10 minutes and is private for now. The manager will also provide the job access to components it needs to perform reconciliation. The skeleton to plumb these components has been added in this patch but the components themselves will come subsequently. References cockroachdb#67679 Release note: None
- Loading branch information
1 parent
3e7ddb3
commit f5d1d74
Showing
32 changed files
with
778 additions
and
33 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "spanconfig", | ||
srcs = [ | ||
"spanconfig.go", | ||
"testing_knobs.go", | ||
], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/spanconfig", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/base", | ||
"//pkg/settings", | ||
], | ||
) |
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,43 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package spanconfig | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/settings" | ||
) | ||
|
||
// CheckAndStartReconciliationJobInterval is a cluster setting to control how | ||
// often the existence of the automatic span config reconciliation job will be | ||
// checked. If the check concludes that the job doesn't exist it will be started. | ||
var CheckAndStartReconciliationJobInterval = settings.RegisterDurationSetting( | ||
"sql.span_config_reconciliation_job.idempotent_start_interval", | ||
"how often to check for the span config reconciliation job exists and start it if it doesn't", | ||
10*time.Minute, | ||
) | ||
|
||
// ReconciliationDependencies captures what's needed by the span config | ||
// reconciliation job to perform its task. The job is responsible for | ||
// reconciling a tenant's zone configurations with the clusters span | ||
// configurations. | ||
type ReconciliationDependencies interface { | ||
// TODO(zcfgs-pod): Placeholder comment until subsequent PRs add useful | ||
// interfaces here. | ||
// The job will want access to two interfaces to reconcile. | ||
// 1. spanconfig.KVAccessor -- this will expose RPCs the job can use to fetch | ||
// span configs from KV and update them. It'll be implemented by Node for the | ||
// host tenant and the Connector for secondary tenants. | ||
// 2. spanconfig.SQLWatcher -- this will maintain a rangefeed over | ||
// system.{descriptors, zones} and be responsible for generating span config | ||
// updates. The job will respond to these updates by issuing RPCs using the | ||
// KVAccessor. | ||
} |
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,15 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "spanconfigjob", | ||
srcs = ["job.go"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/jobs", | ||
"//pkg/jobs/jobspb", | ||
"//pkg/settings/cluster", | ||
"//pkg/sql", | ||
"@com_github_cockroachdb_errors//:errors", | ||
], | ||
) |
Oops, something went wrong.