From 390427087ee253359eb027a4fc0062f7057fe318 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Wed, 26 Oct 2022 17:13:06 +0200 Subject: [PATCH] server: call ReadyFn in secondary tenant servers Release note: None --- pkg/server/tenant.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/server/tenant.go b/pkg/server/tenant.go index 408b22f28a5d..d371ad514da4 100644 --- a/pkg/server/tenant.go +++ b/pkg/server/tenant.go @@ -391,6 +391,17 @@ func (s *SQLServerWrapper) PreStart(ctx context.Context) error { // in _every_ store directory? Not just the first one? } + // Set up calling s.cfg.ReadyFn at the right time. Essentially, this call + // determines when `./cockroach [...] --background` returns. + var onSuccessfulReturnFn func() + { + readyFn := func(bool) {} + if s.sqlServer.cfg.ReadyFn != nil { + readyFn = s.sqlServer.cfg.ReadyFn + } + onSuccessfulReturnFn = func() { readyFn(false /* waitForInit */) } + } + // This opens the main listener. startRPCServer(workersCtx) @@ -416,6 +427,9 @@ func (s *SQLServerWrapper) PreStart(ctx context.Context) error { // TODO(tbg): clarify the contract here and move closer to usage if possible. orphanedLeasesTimeThresholdNanos := s.clock.Now().WallTime + // Signal server readiness to the caller. + onSuccessfulReturnFn() + // Configure the Sentry reporter to add some additional context to reports. // // NB: In (*Server).PreStart(), we can also configure the cluster ID