-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Concurrent map error on text formatter caused by prefixFieldClashes #468
Comments
@kegsay Any chance of running with the race detector? For all intents and purposes, "time", "msg", and "level" should be considered reserved. If you want to add something to the README, please feel free to submit a PR. |
Ideally I would like it for logrus to warn about using those keys, though mentioning in the README that they should be considered reserved is probably also okay. In my particular case, I had innocently added the I'll run it with the race detector and get back to you. |
@kegsay So, it is mentioned in the README. I'm not really sure anything is actionable here. The behavior is documented and emitted messages are clearly not what was expected. Sometimes things are just learning experiences, rather than bugs. ;) Would you like to submit a PR with a warning? That might be a little over-bearing, considering that some users of this package may not want the extra logs emitted for something they've been using for awhile. |
I see what you mean. I guess my main complaint isn't that the keys are in use and I'm silly for using the same key name. Instead, it's that it panics because I used the same key name. If it didn't, I wouldn't have noticed or cared, so I think you're right: the README doesn't need updating and I'm just being grumpy 😆 |
Race detector with links to lines:
So it looks like a hook reads from the entry in a goroutine which is racing with the write for the prefix field. I can confirm that renaming |
@kegsay Grumpy is okay by me! Thanks for the race tracebacks! This isn't exactly ideal. Using IMHO, Line 33 in 12ea3a4
prefixFieldClashes return a new copy would be reasonable (rsc's laments about immutability really come to bear here).
|
Sure, I'll have a stab at this. It should be pretty easy to add a regression test for as well. |
@kegsay do you still reproduce this issue ? I suspect this should be fixed now as we are protecting the entry by a mutex |
Version:
master/a283a10442df8dc09befd873fab202bf8a253d6a
Stack:
Something is writing to
entry.Data
- I've checked my own code and do not see any writes. However,prefixFieldClashes
does modify the map if one of the fields is calledlevel
,msg
ortime
(logrus/formatter.go
Line 33 in 12ea3a4
msg
.I can work around this by renaming the field name on my end, but it would be nice if you could mention that you're modifying keys in the README.
The text was updated successfully, but these errors were encountered: