-
Notifications
You must be signed in to change notification settings - Fork 546
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 while reconnecting #703
Comments
The Write is at
This is part of the code that sends packets that are in the store upon reconnect. The previous read will have been triggred by [email protected]/net.go:293, which is :
This is sending the outgoing packet. So it looks like the following is happening without syncronisation:
This will have an impact on the memory store only (because the file store will load a new copy of the packet from disk) and it's highely unlikely that the operations will occur concurrently, because the previous connection is closed before a reconnect is attempted (and this will lead to the Because of the above, and the fact that the change is always to set I think the prefered fix is to have the Memory store return a copy of the packet, rather than the same bit of memory that is passed in. This would prevent any possibility of the contents of the store being updated unintentionally. |
Thanks for the fast reply and analyses. Does that mean there will be a fix from your side? I assume the fix does not has high prioraty because as you pointed out the race does not have a negative impact (which is absolutly fine for me)? If i want to avoid the data race in my test for now, i should not killing the broker while a publishing is ongoing or did i understood something wrong? |
Probably, eventually. Happy to accept a PR (should just be a matter of copying the response before returning it). Note that using the memory store for QOS1+ means you can loose messages upon restart (I only use the filestore for this reason). |
Ok i will try to fix it this month. |
One of our test fails with a data race if we test our logic we implemented if the client reconnects.
It seems that there is a DATA RACE in the client itself. At least the trace does not show any of our go files/packages.
Trace:
Following Options are set:
KeepAlive: 30s
PingTimeout: 1s
AutoReconnect: true
ConnectTimeout: 10s
ConnectRetry: true
ConnectRetryInterval: 500ms
ResumeSubs: false
The text was updated successfully, but these errors were encountered: