Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: move settingswatcher initialization to the start #97991

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,19 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
// SQL pod server.
_, isMixedSQLAndKVNode := cfg.nodeIDContainer.OptionalNodeID()

var settingsWatcher *settingswatcher.SettingsWatcher
if codec.ForSystemTenant() {
settingsWatcher = settingswatcher.New(
cfg.clock, codec, cfg.Settings, cfg.rangeFeedFactory, cfg.stopper, cfg.settingsStorage,
)
} else {
// Create the tenant settings watcher, using the tenant connector as the
// overrides monitor.
settingsWatcher = settingswatcher.NewWithOverrides(
cfg.clock, codec, cfg.Settings, cfg.rangeFeedFactory, cfg.stopper, cfg.tenantConnect, cfg.settingsStorage,
)
}

sqllivenessKnobs, _ := cfg.TestingKnobs.SQLLivenessKnobs.(*sqlliveness.TestingKnobs)
var sessionEventsConsumer slinstance.SessionEventListener
if !isMixedSQLAndKVNode {
Expand Down Expand Up @@ -1297,19 +1310,6 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
vmoduleSetting.SetOnChange(&cfg.Settings.SV, fn)
fn(ctx)

var settingsWatcher *settingswatcher.SettingsWatcher
if codec.ForSystemTenant() {
settingsWatcher = settingswatcher.New(
cfg.clock, codec, cfg.Settings, cfg.rangeFeedFactory, cfg.stopper, cfg.settingsStorage,
)
} else {
// Create the tenant settings watcher, using the tenant connector as the
// overrides monitor.
settingsWatcher = settingswatcher.NewWithOverrides(
cfg.clock, codec, cfg.Settings, cfg.rangeFeedFactory, cfg.stopper, cfg.tenantConnect, cfg.settingsStorage,
)
}

return &SQLServer{
ambientCtx: cfg.BaseConfig.AmbientCtx,
stopper: cfg.stopper,
Expand Down Expand Up @@ -1365,6 +1365,13 @@ func (s *SQLServer) preStart(
}
}

// Initialize the settings watcher early in sql server startup. Settings
// values are meaningless before the watcher is initialized and most sub
// systems depend on system settings.
if err := s.settingsWatcher.Start(ctx); err != nil {
return errors.Wrap(err, "initializing settings")
}

// Load the multi-region enum by reading the system database's descriptor.
// This also serves as a simple check to see if a tenant exist (i.e. by
// checking whether the system db has been bootstrapped).
Expand Down Expand Up @@ -1499,11 +1506,8 @@ func (s *SQLServer) preStart(
bootstrapVersion = roachpb.Version{Major: 20, Minor: 1, Internal: 1}
}

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

clusterVersionMetrics := clusterversion.MakeMetricsAndRegisterOnVersionChangeCallback(&s.cfg.Settings.SV)
Expand Down