Skip to content

Commit

Permalink
server: hook up settingswatcher to sql server
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
ajwerner committed Dec 30, 2020
1 parent 39d6cfe commit 8e27190
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/scheduledjobs"
"github.com/cockroachdb/cockroach/pkg/security"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/server/settingswatcher"
"github.com/cockroachdb/cockroach/pkg/server/status"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/hydratedtables"
Expand Down Expand Up @@ -97,6 +98,10 @@ type sqlServer struct {
sqlLivenessProvider sqlliveness.Provider
metricsRegistry *metric.Registry

// settingsWatcher is utilized by secondary tenants to watch for settings
// changes. It is nil on the system tenant.
settingsWatcher *settingswatcher.SettingsWatcher

// pgL is the shared RPC/SQL listener, opened when RPC was initialized.
pgL net.Listener
// connManager is the connection manager to use to set up additional
Expand Down Expand Up @@ -636,6 +641,13 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*sqlServer, error) {
leaseMgr,
)

var settingsWatcher *settingswatcher.SettingsWatcher
if !codec.ForSystemTenant() {
settingsWatcher = settingswatcher.New(
cfg.clock, codec, cfg.Settings, cfg.rangeFeedFactory, cfg.stopper,
)
}

return &sqlServer{
pgServer: pgServer,
distSQLServer: distSQLServer,
Expand All @@ -653,6 +665,7 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*sqlServer, error) {
stmtDiagnosticsRegistry: stmtDiagnosticsRegistry,
sqlLivenessProvider: cfg.sqlLivenessProvider,
metricsRegistry: cfg.registry,
settingsWatcher: settingsWatcher,
}, nil
}

Expand Down Expand Up @@ -762,6 +775,12 @@ func (s *sqlServer) preStart(
bootstrapVersion = clusterversion.ByKey(clusterversion.Start20_2)
}

if s.settingsWatcher != nil {
if err := s.settingsWatcher.Start(ctx); err != nil {
return errors.Wrap(err, "initializing settings")
}
}

// Run startup migrations (note: these depend on jobs subsystem running).
if err := sqlmigrationsMgr.EnsureMigrations(ctx, bootstrapVersion); err != nil {
return errors.Wrap(err, "ensuring SQL migrations")
Expand Down

0 comments on commit 8e27190

Please sign in to comment.