Skip to content

Commit

Permalink
spanconfig: get rid of ReconciliationDependencies interface
Browse files Browse the repository at this point in the history
It was hollow, simply embedding the spanconfig.Reconciler interface. In
a future commit we end up relying on each pod's span config reconciler
outside of just the reconciliation job. This makes the interface even
awkwarder than it was.

Release note: None
  • Loading branch information
irfansharif committed Jan 13, 2022
1 parent ab6c601 commit 5d7f4d3
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
spanConfigKnobs,
)

execCfg.SpanConfigReconciliationJobDeps = spanConfig.manager
execCfg.SpanConfigReconciler = spanConfigReconciler
}
execCfg.SpanConfigKVAccessor = cfg.sqlServerOptionalKVArgs.spanConfigKVAccessor

Expand Down
8 changes: 0 additions & 8 deletions pkg/spanconfig/spanconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@ type Reconciler interface {
Checkpoint() hlc.Timestamp
}

// 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 {
Reconciler
}

// Store is a data structure used to store spans and their corresponding
// configs.
type Store interface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/spanconfig/spanconfigjob/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var _ jobs.Resumer = (*resumer)(nil)
// Resume implements the jobs.Resumer interface.
func (r *resumer) Resume(ctx context.Context, execCtxI interface{}) error {
execCtx := execCtxI.(sql.JobExecContext)
rc := execCtx.SpanConfigReconciliationJobDeps()
rc := execCtx.SpanConfigReconciler()

// TODO(irfansharif): #73086 bubbles up retryable errors from the
// reconciler/underlying watcher in the (very) unlikely event that it's
Expand Down
7 changes: 4 additions & 3 deletions pkg/spanconfig/spanconfigmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ var jobEnabledSetting = settings.RegisterBoolSetting(
"enable the use of the kv accessor", false)

// Manager is the coordinator of the span config subsystem. It ensures that
// there's only one span config reconciliation job for every tenant. It also
// there's only one span config reconciliation job[1] for every tenant. It also
// captures all relevant dependencies for the job.
//
// [1]: The reconciliation job is responsible for reconciling a tenant's zone
// configurations with the clusters span configurations.
type Manager struct {
db *kv.DB
jr *jobs.Registry
Expand All @@ -64,8 +67,6 @@ type Manager struct {
spanconfig.Reconciler
}

var _ spanconfig.ReconciliationDependencies = &Manager{}

// New constructs a new Manager.
func New(
db *kv.DB,
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,9 +1226,9 @@ type ExecutorConfig struct {
// CollectionFactory is used to construct a descs.Collection.
CollectionFactory *descs.CollectionFactory

// SpanConfigReconciliationJobDeps are used to drive the span config
// reconciliation job.
SpanConfigReconciliationJobDeps spanconfig.ReconciliationDependencies
// SpanConfigReconciler is used to drive the span config reconciliation job
// and related migrations.
SpanConfigReconciler spanconfig.Reconciler

// SpanConfigKVAccessor is used when creating and deleting tenant
// records.
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/job_exec_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func (e *plannerJobExecContext) User() security.SQLUsername { return e.p.Us
func (e *plannerJobExecContext) MigrationJobDeps() migration.JobDeps {
return e.p.MigrationJobDeps()
}
func (e *plannerJobExecContext) SpanConfigReconciliationJobDeps() spanconfig.ReconciliationDependencies {
return e.p.SpanConfigReconciliationJobDeps()
func (e *plannerJobExecContext) SpanConfigReconciler() spanconfig.Reconciler {
return e.p.SpanConfigReconciler()
}

// JobExecContext provides the execution environment for a job. It is what is
Expand All @@ -84,5 +84,5 @@ type JobExecContext interface {
LeaseMgr() *lease.Manager
User() security.SQLUsername
MigrationJobDeps() migration.JobDeps
SpanConfigReconciliationJobDeps() spanconfig.ReconciliationDependencies
SpanConfigReconciler() spanconfig.Reconciler
}
4 changes: 2 additions & 2 deletions pkg/sql/job_exec_context_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (p *FakeJobExecContext) MigrationJobDeps() migration.JobDeps {
panic("unimplemented")
}

// SpanConfigReconciliationJobDeps implements the JobExecContext interface.
func (p *FakeJobExecContext) SpanConfigReconciliationJobDeps() spanconfig.ReconciliationDependencies {
// SpanConfigReconciler implements the JobExecContext interface.
func (p *FakeJobExecContext) SpanConfigReconciler() spanconfig.Reconciler {
panic("unimplemented")
}
2 changes: 1 addition & 1 deletion pkg/sql/planhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type PlanHookState interface {
CreateSchemaNamespaceEntry(ctx context.Context, schemaNameKey roachpb.Key,
schemaID descpb.ID) error
MigrationJobDeps() migration.JobDeps
SpanConfigReconciliationJobDeps() spanconfig.ReconciliationDependencies
SpanConfigReconciler() spanconfig.Reconciler
BufferClientNotice(ctx context.Context, notice pgnotice.Notice)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,9 @@ func (p *planner) MigrationJobDeps() migration.JobDeps {
return p.execCfg.MigrationJobDeps
}

// SpanConfigReconciliationJobDeps returns the spanconfig.ReconciliationJobDeps.
func (p *planner) SpanConfigReconciliationJobDeps() spanconfig.ReconciliationDependencies {
return p.execCfg.SpanConfigReconciliationJobDeps
// SpanConfigReconciler returns the spanconfig.Reconciler.
func (p *planner) SpanConfigReconciler() spanconfig.Reconciler {
return p.execCfg.SpanConfigReconciler
}

// GetTypeFromValidSQLSyntax implements the tree.EvalPlanner interface.
Expand Down

0 comments on commit 5d7f4d3

Please sign in to comment.