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 span config subsystem and its orchestrator, the spanconfig.Manager. The span config manager is owns the process of reconciling SQL zone configs to KV span configs. This includes managing the span config reconciliation job and providing it access to dependencies it needs to perform reconciliation. The span config reconciliation job is intended to be a per tenant, forever running job that is non-cancellable. At any point there should be one (and only one) of these jobs running. The manager helps ensure these semantics. Even though we expect this job to be forever running (and therefore never transition to a failed state), the manager on every sql pod will periodically ensure that the job is indeed running. It will restart a new job in case it finds that the job is not running. The interval at which this happens is dictated by the `sql.span_config_reconciliation_job.idempotent_start_interval` cluster setting. It defaults to 10 minutes and is private for now. This patch only adds the skeleton to encapsulate and plumb dependencies to the job. The specific components themselves will come in subsequent patches. References cockroachdb#67679 Release note: None
- Loading branch information
1 parent
38463fd
commit fd0af6e
Showing
32 changed files
with
818 additions
and
33 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
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,57 @@ | ||
// 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 ( | ||
"context" | ||
"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, | ||
settings.NonNegativeDuration, | ||
) | ||
|
||
// Manager is the coordinator of the span config subsystem. It is responsible | ||
// for the following tasks: | ||
// | ||
// 1. Ensuring that one (and only one) span config reconciliation job exists for | ||
// every tenant. | ||
// 2. Encapsulating all dependencies required by the span config reconciliation | ||
// job to perform its task. | ||
type Manager interface { | ||
Start(ctx context.Context) error | ||
ReconciliationDependencies | ||
} | ||
|
||
// 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 | ||
} |
Oops, something went wrong.