chore: fix logging issues in Store.loadShards

Fix reporting shards not opening correctly when they actually did.
Fix race condition with logging in loadShards.
gw_fix_load_log
Geoffrey Wossum 2024-11-08 17:29:49 -06:00
parent 0bc167bbd7
commit aed9e976ed
No known key found for this signature in database
GPG Key ID: 02E7AAF2176D7846
1 changed files with 3 additions and 4 deletions

View File

@ -567,14 +567,13 @@ func (s *Store) loadShards() error {
loader := s.newShardLoader(sh.id, sh.db, sh.rp, false, withIndexVersion(indexVersion))
// Now perform the actual loading in parallel in separate goroutines.
go func() {
go func(log *zap.Logger) {
t.Take()
defer t.Release()
log := log.With(logger.Shard(sh.id), zap.String("path", loader.path))
start := time.Now()
res := loader.Load()
if res.err != nil {
if res.err == nil {
log.Info("Opened shard", zap.String("index_version", res.s.IndexType()), zap.Duration("duration", time.Since(start)))
} else {
log.Error("Failed to open shard", zap.Error(res.err))
@ -584,7 +583,7 @@ func (s *Store) loadShards() error {
if s.startupProgressMetrics != nil {
s.startupProgressMetrics.CompletedShard()
}
}()
}(log.With(logger.Shard(sh.id), zap.String("path", loader.path)))
}
// Register shards serially as the parallel goroutines finish opening them.