-
Notifications
You must be signed in to change notification settings - Fork 615
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
Data race in dispatcher - dispatcher.mu locking vs dispatcher.rpcRW locking #2577
Comments
I think this can be ignored since isRunning() is a read-only op and if it reads stale value the only down side is an extra heartbeat processing.
Merging mu and rpcRW is neither easy nor worth the effort. See #2525 |
I agree that stale reads would be ok, but in general I'd prefer not to ignore data race warnings from the compiler since (1) we have to keep track of which ones are ok, and which ones aren't, and it'd be simpler if we should always just try to make CI pass. And (2) I think some go authors have specifically said that a data race is undefined behavior in golang, and the compiled code isn't guaranteed to behave correctly: https://groups.google.com/forum/#!topic/golang-nuts/EHHMCdcenc8 |
Fair point. I'd definitely be interested in hearing ideas on how to address this without calling isRunningLocked() on every heartbeat. |
Hmm... can we move the |
Actually, thought about this more and I don't think it will not work. The streaming RPCs grab the read lock at the start of the function and hold on to the read lock until the context is cancelled. If the context is cancelled inside the write lock, then it'll never happen because the read lock will locked by the streaming RPC. @cyli |
closed by #2664 |
Just saw the following data race while running tests:
The data race seems to be coming from this call of
isRunning
instead ofisRunningLocked
: https://github.com/docker/swarmkit/blob/master/manager/dispatcher/dispatcher.go#L1152Not sure if the thing to do is to call
isRunningLocked
instead, or to mergemu
andrpcRW
.The text was updated successfully, but these errors were encountered: