Skip to content

Commit

Permalink
multitenant: secondary tenant SQL server startup guardrails
Browse files Browse the repository at this point in the history
This code change prevents a SQL server for a secondary tenant
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 81aae3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,18 @@ func (s *SQLServer) preStart(
if err := s.settingsWatcher.Start(ctx); err != nil {
return errors.Wrap(err, "initializing settings")
}

// Prevent a secondary tenant's server from starting if its binary version is too low
// for the current tenant cluster version.
if !s.execCfg.Codec.ForSystemTenant() {
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 81aae3f

Please sign in to comment.