From f4c6eba68754df8a47cad5378b6a208bab6625a2 Mon Sep 17 00:00:00 2001 From: ajwerner Date: Thu, 9 Mar 2023 19:26:45 -0500 Subject: [PATCH] sql: use CachedReader for uses with sqlinstance and the sql builtin The CachedReader won't block, which in multi-region clusters is good. It will mean that in some cases, it'll state that a sessions is alive when it most certainly is not. Currently, nobody needs synchronous semantics. This is a major part of fixing the TestColdStartLatency as sometimes distsql planning would block. That's not acceptable -- the idea that query physical planning can need to wait for a cross-region RPC is unacceptable. Release note: None --- pkg/server/server_sql.go | 4 ++-- pkg/sql/planner.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/server/server_sql.go b/pkg/server/server_sql.go index 652da7e7ab56..1f853486baf7 100644 --- a/pkg/server/server_sql.go +++ b/pkg/server/server_sql.go @@ -562,7 +562,7 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) { cfg.clock, cfg.rangeFeedFactory, ) cfg.sqlInstanceReader = instancestorage.NewReader( - cfg.sqlInstanceStorage, cfg.sqlLivenessProvider.BlockingReader(), + cfg.sqlInstanceStorage, cfg.sqlLivenessProvider.CachedReader(), cfg.stopper, ) @@ -789,7 +789,7 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) { RowMetrics: &rowMetrics, InternalRowMetrics: &internalRowMetrics, - SQLLivenessReader: cfg.sqlLivenessProvider.BlockingReader(), + SQLLivenessReader: cfg.sqlLivenessProvider.CachedReader(), JobRegistry: jobRegistry, Gossip: cfg.gossip, PodNodeDialer: cfg.podNodeDialer, diff --git a/pkg/sql/planner.go b/pkg/sql/planner.go index f061ce630dc2..89f5a63c1379 100644 --- a/pkg/sql/planner.go +++ b/pkg/sql/planner.go @@ -114,7 +114,7 @@ func (evalCtx *extendedEvalContext) copyFromExecCfg(execCfg *ExecutorConfig) { evalCtx.Settings = execCfg.Settings evalCtx.Codec = execCfg.Codec evalCtx.Tracer = execCfg.AmbientCtx.Tracer - evalCtx.SQLLivenessReader = execCfg.SQLLiveness.BlockingReader() + evalCtx.SQLLivenessReader = execCfg.SQLLiveness.CachedReader() evalCtx.CompactEngineSpan = execCfg.CompactEngineSpanFunc evalCtx.SetCompactionConcurrency = execCfg.CompactionConcurrencyFunc evalCtx.TestingKnobs = execCfg.EvalContextTestingKnobs