-
Notifications
You must be signed in to change notification settings - Fork 69
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
opamp.Connection needs a Mutex to avoid concurrent write panic #90
Comments
This is working as intended per the Connection interface: opamp-go/server/types/connection.go Lines 16 to 21 in 3f2eab4
I will do some benchmarking with a large number of connections to determine the overhead of adding a mutex per connection. |
FYI, we protect the connection with a mutex in our example. So it seems reasonable to just move this mutex inside the connection struct and have proper encapsulation. One argument against having the mutex in the connection is that in the server implementation one may have a mutex per agent anyway (e.g. to protect agent's data fields) and that same mutex can be used to protect the connection. However, we don't do it in our example (we have a separate mutex for data fields) so perhaps the combined mutex is not such a good option (otherwise why don't we use it?). |
I missed this issue while working on #200. In my opinion having separate mutexes for the WS connection and the agent data fields makes sense because the cost of the mutexes is low and it would cause contention between updating the agent and sending it messages if we had a shared mutex. @andykellr @tigrannajaryan Are we satisfied that this is resolved? |
Yes, I think we can close this. |
In a busy server, we encountered a concurrent write panic. I added protection in the server, but ideally the library would add a Mutex to prevent this from happening.
Here is the relevant stack fragment:
The text was updated successfully, but these errors were encountered: