apex / apex/log

fatal error: concurrent map iteration and map write

未关闭
#74 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Go
星标
1.4k
派生
110
PR 合并指标
30 天内没有已合并 PR

描述

We experienced a crash today that I'm having trouble diagnosing. The error occurred when calling `logger.Info` inside a goroutine. There were several parallel tasks, all which log when they complete. This code has been running, unchanged for months and I don't believe we've had any issues before.

Are `logger.WithField` and `logger.WithError` intended to be threadsafe?

Thanks in advance.

----

The error occurs at line 155 in `(e *Entry) mergedFields`

```go
151 func (e *Entry) mergedFields() Fields {
152 f := Fields{}
153
154 for _, fields := range e.fields {
155 for k, v := range fields {
156 f[k] = v
157 }
158 }
159
160 return f
161 }
```

```
/usr/lib/golang/src/runtime/panic.go:617 +0x72 fp=0xc001167d48 sp=0xc001167d18 pc=0x43a112
runtime.mapiternext(0xc001167e28)
/usr/lib/golang/src/runtime/map.go:860 +0x597 fp=0xc001167dd0 sp=0xc001167d48 pc=0x41ccd7
vendor/github.com/apex/log.(*Entry).mergedFields(0xc00017d260, 0x14)
/go/src/vendor/github.com/apex/log/entry.go:155 +0x6c fp=0xc001167e98 sp=0xc001167dd0 pc=0x77aeac
vendor/github.com/apex/log.(*Entry).finalize(0xc00017d260, 0x1, 0x1779ed3, 0x1c, 0x0)
/go/src/vendor/github.com/apex/log/entry.go:167 +0x2f fp=0xc001167ee0 sp=0xc001167e98 pc=0x77afef
vendor/github.com/apex/log.(*Logger).log(0x2978830, 0x1, 0xc00017d260, 0x1779ed3, 0x1c)
/go/src/vendor/github.com/apex/log/logger.go:146 +0x5c fp=0xc001167f28 sp=0xc001167ee0 pc=0x77c31c
vendor/github.com/apex/log.(*Entry).Info(...)
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。