[MM-27952] Fix some logging related races (#15404)
* Fix some logging races * Move initLogging after config store initialization
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
44079785eb
Коммит
4c518055f4
@@ -184,7 +184,6 @@ func NewServer(options ...Option) (*Server, error) {
|
|||||||
hashSeed: maphash.MakeSeed(),
|
hashSeed: maphash.MakeSeed(),
|
||||||
}
|
}
|
||||||
|
|
||||||
mlog.Info("Server is initializing...")
|
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
if err := option(s); err != nil {
|
if err := option(s); err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to apply option")
|
return nil, errors.Wrap(err, "failed to apply option")
|
||||||
@@ -204,6 +203,9 @@ func NewServer(options ...Option) (*Server, error) {
|
|||||||
mlog.Error(err.Error())
|
mlog.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is called after initLogging() to avoid a race condition.
|
||||||
|
mlog.Info("Server is initializing...")
|
||||||
|
|
||||||
// It is important to initialize the hub only after the global logger is set
|
// It is important to initialize the hub only after the global logger is set
|
||||||
// to avoid race conditions while logging from inside the hub.
|
// to avoid race conditions while logging from inside the hub.
|
||||||
fakeApp := New(ServerConnector(s))
|
fakeApp := New(ServerConnector(s))
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func NewTestingLogger(tb testing.TB, writer io.Writer) *Logger {
|
|||||||
logrLogger: newLogr(),
|
logrLogger: newLogr(),
|
||||||
}
|
}
|
||||||
|
|
||||||
logWriterCore := zapcore.NewCore(makeEncoder(true), logWriterSync, testingLogger.consoleLevel)
|
logWriterCore := zapcore.NewCore(makeEncoder(true), zapcore.Lock(logWriterSync), testingLogger.consoleLevel)
|
||||||
|
|
||||||
testingLogger.zap = zap.New(logWriterCore,
|
testingLogger.zap = zap.New(logWriterCore,
|
||||||
zap.AddCaller(),
|
zap.AddCaller(),
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user