Skip to content
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

fix race conditions on entry #1047

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

lwsanty
Copy link
Contributor

@lwsanty lwsanty commented Oct 23, 2019

closes #1046

@bconway
Copy link

bconway commented Feb 26, 2020

This is still a bug. It can occur with any use of Entry and a hook (i.e. logrustash).

@stale stale bot removed the stale label Feb 26, 2020
Repository owner deleted a comment from stale bot Feb 26, 2020
@markphelps markphelps merged commit 77ab282 into sirupsen:master Feb 26, 2020
@markphelps
Copy link
Collaborator

markphelps commented Feb 26, 2020

Thank you @blocknonip and @lwsanty!!. Sorry for the stalebot spam. I thought it would only label/comment on issues, not PRs too.

@flimzy
Copy link
Contributor

flimzy commented Mar 27, 2020

This lock is far too aggressive. It locks the entire logger, rather than a single entry as I believe it should.

@dgsb
Copy link
Collaborator

dgsb commented Mar 27, 2020

Agree, we should find a better solution than this one.

@markphelps
Copy link
Collaborator

@flimzy my apologies for merging this so quickly. would you want to work on a PR to lock only the entry? If not I can early this coming week.

@flimzy
Copy link
Contributor

flimzy commented Mar 29, 2020

I looked at it briefly before posting my comment, and it wasn't immediately obvious the proper solution. It looks like we need to add a mutex to the Entry type, and lock it in WithFields and in fireHooks, but my first attempt lead to a deadlock.

While working on that, I ran into what may be other overly-aggressive locks which could be relaxed, too, but it's tricky to do that with confidence, without tests covering all possible races (which are incredibly hard to test).

I'll try again if I have time, but you may get to it faster than me.

@markphelps
Copy link
Collaborator

@flimzy ok I created #1122 to track. I'll also try taking a look

markphelps added a commit that referenced this pull request Apr 16, 2020
@markphelps markphelps mentioned this pull request Apr 16, 2020
markphelps added a commit that referenced this pull request Apr 16, 2020
cgxxv pushed a commit to cgxxv/logrus that referenced this pull request Mar 25, 2022
cgxxv pushed a commit to cgxxv/logrus that referenced this pull request Mar 25, 2022
cgxxv pushed a commit to cgxxv/logrus that referenced this pull request Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition in entry.Data on calling WithFields() method
5 participants