Skip to content

Commit

Permalink
server: fix a race condition during server initialization
Browse files Browse the repository at this point in the history
The call to `registerEnginesForDiskStatsMap` needs to wait until the
store IDs are known.

Release note: None
  • Loading branch information
knz committed Apr 10, 2023
1 parent 85e41ca commit 2f4cd92
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,13 @@ func (s *Server) PreStart(ctx context.Context) error {
// to bypass admission control.
s.storeGrantCoords.SetPebbleMetricsProvider(ctx, s.node, s.node)

// Connect the engines to the disk stats map constructor.
// This also needs to wait until after `waitForAdditionalStoreInit` returns,
// as the store IDs may not be known until then.
if err := s.node.registerEnginesForDiskStatsMap(s.cfg.Stores.Specs, s.engines); err != nil {
return errors.Wrapf(err, "failed to register engines for the disk stats map")
}

// Once all stores are initialized, check if offline storage recovery
// was done prior to start and record any actions appropriately.
logPendingLossOfQuorumRecoveryEvents(workersCtx, s.node.stores)
Expand Down Expand Up @@ -1938,11 +1945,6 @@ func (s *Server) PreStart(ctx context.Context) error {
}
}

// Connect the engines to the disk stats map constructor.
if err := s.node.registerEnginesForDiskStatsMap(s.cfg.Stores.Specs, s.engines); err != nil {
return errors.Wrapf(err, "failed to register engines for the disk stats map")
}

if storage.WorkloadCollectorEnabled {
if err := s.debug.RegisterWorkloadCollector(s.node.stores); err != nil {
return errors.Wrapf(err, "failed to register workload collector with debug server")
Expand Down

0 comments on commit 2f4cd92

Please sign in to comment.