-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
StatsManager is not thread safe #3869
Comments
It's protected by nameMapLock_. |
No, nameMapLock_ protect another map. You can find some other places where stat_ is used without lock. |
It protects stats_ too, add/delete counter will lock nameMapLock_ firstly. |
But reading stat_ doesn't with Lock. If one thread read stat_'s element while another thread insert/erase some element, this may be lead to structure modify of unordered_map. Reading thread will access some released memory. |
Yes, read need protection too. |
And I think this part requires some complex design rather than simply using read-write locks. The performance of the lock is very poor, and the metric cannot affect the performance of the system. |
Agree, in my mind, static lifetime metric is enough. |
Describe the bug (required)
stats_
is astd::unordered_map
. And some time will read/write without lockThe text was updated successfully, but these errors were encountered: