-
Notifications
You must be signed in to change notification settings - Fork 443
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
Memberlist.Members safe use docstring #250
Comments
Thank you for opening this issue! A PR to document safe usage of this method would be great! I fixed a related data race in #232, but I don't think it addresses this problem. While working on that PR I noticed this problem you describe also exists with As for a better solution, it would probably be better to return a non-pointer, but that would be a breaking change. So I think for now documenting it is best. We'll have to look at a better longer term solution for a v2. |
with the Prometheus alert manager. Resolves hashicorp#250
Hi, any feedback welcome on my PR to document the issue, thanks. |
memberlist/memberlist.go
Line 597 in 923f1b2
Hi! TL;DR;
Memberlist.Members function docstring missing warning that reading through the pointers can lead to data race.
We've seen it trigger race detection once in tests for Prometheus Alertmanager.
The issue is with prometheus/alertmanager#1428 that introduced checking addresses via the Node pointers to verify that expected members are there.
Would you accept a PR to mention the potential for data race in the docstring?
What would be a better solution? Would it make sense to copy the Nodes/Addresses under mutex?
Thanks in advance, krajo
Info:
I could not reproduce the issue with this test, but it is possible to write a synthetic test to trigger the race detector:
The text was updated successfully, but these errors were encountered: