Skip to content

Commit

Permalink
multitenant: add SQL server startup guardrails
Browse files Browse the repository at this point in the history
This code change prevents a SQL server from starting if its
binary version is less than the tenant's active version.

Release note: None
Epic: CRDB-10829
  • Loading branch information
healthy-pod committed Jan 10, 2023
1 parent 01032c2 commit 709565a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,16 @@ func (s *SQLServer) preStart(
if err := s.settingsWatcher.Start(ctx); err != nil {
return errors.Wrap(err, "initializing settings")
}

// Prevent the server from starting if its binary version is too low
// for the current tenant cluster version.
tenantActiveVersion := s.settingsWatcher.GetTenantClusterVersion().ActiveVersion(ctx).Version
if s.execCfg.Settings.Version.BinaryVersion().Less(tenantActiveVersion) {
return errors.Newf("preventing SQL server from starting because its binary version "+
"is too low for the tenant active version: server binary version = %v, tenant active version = %v",
s.execCfg.Settings.Version.BinaryVersion(), tenantActiveVersion)
}

if err := s.systemConfigWatcher.Start(ctx, s.stopper); err != nil {
return errors.Wrap(err, "initializing settings")
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/settingswatcher/settings_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,7 @@ func (s *SettingsWatcher) GetStorageClusterVersion() clusterversion.ClusterVersi
}
return s.mu.storageClusterVersion
}

func (s *SettingsWatcher) GetTenantClusterVersion() clusterversion.Handle {
return s.settings.Version
}

0 comments on commit 709565a

Please sign in to comment.