-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Use atomic.Load to access fields used in /varz and /subsz requests. #445
Conversation
* Includes a unit test that checks all endpoints for data races.
The data race behind this PR:
After the fix here:
|
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.
Small comments, otherwise looks good.
For some reason, the coverall result is not displayed in the PR?!
server/sublist.go
Outdated
st.NumMatches = s.matches | ||
if s.matches > 0 { | ||
st.CacheHitRate = float64(s.cacheHits) / float64(s.matches) | ||
st.NumInserts = atomic.LoadUint64(&s.inserts) |
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.
Looks like s.inserts
and s.removes
are updated under sublist's lock, so I don't think you need atomic for those 2.
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.
Thanks, will fix.
opts2.Routes = server.RoutesFromStr("nats-route://127.0.0.1:10223") | ||
|
||
s2 := RunServer(&opts2) | ||
|
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.
You may want to call checkClusterFormed(t, s1, s2)
here to ensure cluster is formed, instead of using time.Sleep(2 * time.Second)
in the caller. You would need to pass t *testing.T
as parameter to runMonitorServerClusteredPair()
.
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.
Sounds good here.
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.
Done.
test/monitor_test.go
Outdated
defer s2.Shutdown() | ||
|
||
// give some time for a route to form | ||
time.Sleep(2 * time.Second) |
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.
See comment in runMonitorServerClusteredPair()
Changes Unknown when pulling efbd423 on fix-monitoring-data-races into ** on master**. |
Sorry for the delay, LGTM. |
LGTM. Looks like coveralls error is a known, unresolved issue. |
Resolves #NNN
(N/A, included test demonstrates the issue)git pull --rebase origin master
)/cc @nats-io/core