New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
please help to resolve race-condition in zerolog #555
Comments
Slach
added a commit
to Altinity/clickhouse-backup
that referenced
this issue
Jun 13, 2023
…erolog.Disabled
Slach
added a commit
to Altinity/clickhouse-backup
that referenced
this issue
Jun 14, 2023
… ConsoleWriter, increase some clickhouse timeout in test config, cause clickhouse-go/v2 got some timeouts during execution
Slach
added a commit
to Altinity/clickhouse-backup
that referenced
this issue
Jun 14, 2023
…logger in upload.go
Slach
added a commit
to Altinity/clickhouse-backup
that referenced
this issue
Jun 14, 2023
… try to remove all local loggers with context upload.go
mskwon
pushed a commit
to mskwon/clickhouse-backup
that referenced
this issue
Jun 14, 2023
…erolog.Disabled
@Slach could you try this?
Trying to confirm if that might help. |
@sruehl I can't thank you enough, it works, you save many debug hours |
Slach
added a commit
to Altinity/clickhouse-backup
that referenced
this issue
Aug 12, 2023
… gone away, need pull and resolve conflicts from master
=( but found race condition in other place
backup/download.go:412 // simple import zerolog
import (
"github.com/rs/zerolog/log"
)
func (b *Backuper) downloadTableMetadata(ctx context.Context, backupName string, disks []clickhouse.Disk, tableTitle metadata.TableTitle, schemaOnly bool, partitions []string) (*metadata.TableMetadata, uint64, error) {
...
log.Info().
Str("operation", "download_metadata").
Str("backup", backupName).
Str("duration", utils.HumanizeDuration(time.Since(start))).
Str("size", utils.FormatBytes(size)).
Msg("done")
return &tableMetadata, size, nil
} just one function without instances of zerolog.Logger, which called inside pool of go-routines downloadSemaphore := semaphore.NewWeighted(int64(b.cfg.General.DownloadConcurrency))
metadataGroup, metadataCtx := errgroup.WithContext(ctx)
for i, t := range tablesForDownload {
...
metadataGroup.Go(func() error {
defer downloadSemaphore.Release(1)
if err != nil {
return err
}
})
}
if err := metadataGroup.Wait(); err != nil {
return fmt.Errorf("one of Download Metadata go-routine return error: %v", err)
} Any ideas why it happen? and how to resolve it? main.go import (
stdlog "log"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/pkgerrors"
)
func main() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnixMs
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout, NoColor: true, TimeFormat: "2006-01-02 15:04:05.000"}
log.Logger = zerolog.New(zerolog.SyncWriter(consoleWriter)).With().Timestamp().Caller().Logger()
stdlog.SetOutput(log.Logger)
...
} |
Slach
added a commit
to Altinity/clickhouse-backup
that referenced
this issue
Aug 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@rs
i have race-condition ;(
https://github.com/Altinity/clickhouse-backup/actions/runs/5259410860/jobs/9504979925#step:7:2222
when try to use zerolog with multiple go-routines + errorgroup
LogQuery() related code
How race condition possible here?
i redefine
log.Logger
once in main functionand after it use copy of logger
Logger: log.With().Str("logger", "clickhouse").Logger(),
and copy of copy
logger := ch.Logger.With().Logger()
during execution of With() it shall create copy of
Logger
what i'm doing wrong?
The text was updated successfully, but these errors were encountered: