-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
progressWriter data race #4011
base: master
Are you sure you want to change the base?
progressWriter data race #4011
Conversation
before fixing:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what exactly is causing the race in here. Is it p.meta
or pw.meta
. If pw.meta
, then where is it getting modified?
the progress writer can be used from multiple threads and requires locking. Signed-off-by: Alex Couture-Beil <[email protected]>
85b57be
to
c2757d8
Compare
I had a closer look, and discovered I left off the
it's which are reproducible by running
This was quite the deep-dive into the solver progress code, but it looks like: under
Then along the ways the Status thread makes a call to |
I think it would probably be better to avoid adding a mutex. Based on the stacktraces and the explanation given, I think it would be better to update the section of code that you have to create a new progress struct with the new metadata rather than modify the existing one. Something like: func (p *Progress) WithMeta(meta map[string]interface{}) *Progress {
newP := *p
newP.meta = meta
return &newP
} While a mutex would solve it, it seems like an error that we can have a multi writer and one of the multi writers could modify the meta of the progress object for the other unrelated writers. Duplicating the object and replacing the meta object would resolve the race condition while also preserving the meta object for the other writers. |
the progress writer can be used from multiple threads and requires locking.