From 81aae3feeb6e9676a774989c7803c0bed199dacf Mon Sep 17 00:00:00 2001 From: healthy-pod Date: Mon, 9 Jan 2023 12:56:08 -0800 Subject: [PATCH] multitenant: secondary tenant SQL server startup guardrails 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 --- pkg/server/server_sql.go | 12 ++++++++++++ pkg/server/settingswatcher/settings_watcher.go | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/pkg/server/server_sql.go b/pkg/server/server_sql.go index 98ef2f815b63..ea141d4f48f8 100644 --- a/pkg/server/server_sql.go +++ b/pkg/server/server_sql.go @@ -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") } diff --git a/pkg/server/settingswatcher/settings_watcher.go b/pkg/server/settingswatcher/settings_watcher.go index a5733e35ee59..ffb11b36aa50 100644 --- a/pkg/server/settingswatcher/settings_watcher.go +++ b/pkg/server/settingswatcher/settings_watcher.go @@ -440,3 +440,7 @@ func (s *SettingsWatcher) GetStorageClusterVersion() clusterversion.ClusterVersi } return s.mu.storageClusterVersion } + +func (s *SettingsWatcher) GetTenantClusterVersion() clusterversion.Handle { + return s.settings.Version +}