From aeffaed145bf15d141452cbb71f3b83cb39f7fca Mon Sep 17 00:00:00 2001 From: Steven Danna Date: Mon, 6 Nov 2023 13:07:02 +0000 Subject: [PATCH] server: use a single setting for tenant waiting We can use a zero-wait time to indicate no waiting, saving a cluster setting. Epic: none Release note: None --- pkg/multitenant/tenant_config.go | 16 +++------------- pkg/server/server_controller_sql.go | 2 +- pkg/server/server_controller_test.go | 5 ++++- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/pkg/multitenant/tenant_config.go b/pkg/multitenant/tenant_config.go index aee5bb7488bf..62795c08fdbb 100644 --- a/pkg/multitenant/tenant_config.go +++ b/pkg/multitenant/tenant_config.go @@ -43,22 +43,12 @@ var VerifyTenantService = settings.RegisterBoolSetting( settings.WithName(DefaultClusterSelectSettingName+".check_service.enabled"), ) -// WaitForClusterStart, if enabled, instructs the tenant controller to -// wait up to WaitForClusterStartTimeout for the defuault virtual -// cluster to have an active SQL server. -var WaitForClusterStart = settings.RegisterBoolSetting( - settings.SystemOnly, - "server.controller.mux_virtual_cluster_wait.enabled", - "wait up to server.controller_mux_virtual_cluster_wait.timeout for the default virtual cluster to become available for SQL connections", - false, -) - -// WaitForClusterStartTimeout is the amoutn of time the the tenant +// WaitForClusterStartTimeout is the amount of time the tenant // controller will wait for the default virtual cluster to have an -// active SQL server, if WaitForClusterStart is true. +// active SQL server. var WaitForClusterStartTimeout = settings.RegisterDurationSetting( settings.SystemOnly, "server.controller.mux_virtual_cluster_wait.timeout", - "amount of time to wait for a default virtual cluster to become available when serving SQL connections", + "amount of time to wait for a default virtual cluster to become available when serving SQL connections (0 to disable)", 10*time.Second, ) diff --git a/pkg/server/server_controller_sql.go b/pkg/server/server_controller_sql.go index 135b745406c7..9632dd1168d6 100644 --- a/pkg/server/server_controller_sql.go +++ b/pkg/server/server_controller_sql.go @@ -110,7 +110,7 @@ func (c *serverController) shouldWaitForTenantServer(name roachpb.TenantName) bo return false } - return multitenant.WaitForClusterStart.Get(&c.st.SV) + return multitenant.WaitForClusterStartTimeout.Get(&c.st.SV) > 0 } func (c *serverController) waitForTenantServer( diff --git a/pkg/server/server_controller_test.go b/pkg/server/server_controller_test.go index 0c100ec9994a..b3132fa5d112 100644 --- a/pkg/server/server_controller_test.go +++ b/pkg/server/server_controller_test.go @@ -22,6 +22,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" + "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/errors" @@ -138,7 +139,9 @@ func TestServerControllerWaitForDefaultCluster(t *testing.T) { defer s.Stopper().Stop(ctx) sqlRunner := sqlutils.MakeSQLRunner(db) - sqlRunner.Exec(t, "SET CLUSTER SETTING server.controller.mux_virtual_cluster_wait.enabled = true") + if util.RaceEnabled { + sqlRunner.Exec(t, "SET CLUSTER SETTING server.controller.mux_virtual_cluster_wait.timeout = '1m'") + } tryConnect := func() error { conn, err := s.SystemLayer().SQLConnE(serverutils.DBName("cluster:hello"))