[question] why `SetLevelFromString` and `SetLevel` are not thread-safe?
Slach opened this issue · comments
I want to reload config and setup global log level dynamically
But got race conditions
could you give any suggestions how to do it?
WARNING: DATA RACE
Write at 0x00000532fb30 by goroutine 94:
github.com/apex/log.SetLevelFromString()
/root/go/pkg/mod/github.com/apex/log@v1.9.0/pkg.go:29 +0xd3
github.com/AlexAkulov/clickhouse-backup/pkg/config.LoadConfig()
/src/pkg/config/config.go:280 +0xb44
github.com/AlexAkulov/clickhouse-backup/pkg/backup.(*Backuper).Watch()
/src/pkg/backup/watch.go:95 +0x68e
github.com/AlexAkulov/clickhouse-backup/pkg/server.(*APIServer).RunWatch()
/src/pkg/server/server.go:140 +0x48e
github.com/AlexAkulov/clickhouse-backup/pkg/server.Run.func2()
/src/pkg/server/server.go:109 +0x5b
Previous read at 0x00000532fb30 by goroutine 93:
github.com/apex/log.(*Logger).log()
/root/go/pkg/mod/github.com/apex/log@v1.9.0/logger.go:149 +0x8c
github.com/apex/log.(*Entry).Info()
/root/go/pkg/mod/github.com/apex/log@v1.9.0/entry.go:96 +0x94
github.com/apex/log.(*Entry).Infof()
/root/go/pkg/mod/github.com/apex/log@v1.9.0/entry.go:122 +0xec
github.com/apex/log.(*Logger).Infof()
/root/go/pkg/mod/github.com/apex/log@v1.9.0/logger.go:121 +0xe4
github.com/apex/log.Infof()
/root/go/pkg/mod/github.com/apex/log@v1.9.0/pkg.go:86 +0xc5
github.com/AlexAkulov/clickhouse-backup/pkg/server.(*APIServer).UpdateBackupMetrics()
/src/pkg/server/server.go:1148 +0x1c4
github.com/AlexAkulov/clickhouse-backup/pkg/server.Run.func1()
/src/pkg/server/server.go:103 +0xa4