[-]: fix race conditions in 'fileMetricReader', fixes #1198#1199
[-]: fix race conditions in 'fileMetricReader', fixes #1198#1199gemy26 wants to merge 4 commits intocybertec-postgresql:masterfrom
Conversation
0xgouda
left a comment
There was a problem hiding this comment.
No need to duplicate mu.Lock() mu.Unlock() everywhere we only need it around the critical section in the shared fmr.WriteMetrics()
Also, we should use RWLock instead, and lock the critical section in getMetrics() while reading.
Also, please do the same for yaml sources handler
|
Thanks for reply, |
|
Oh yeah, you are right, sorry for that, I got a bit confused. But we still should use RWLocks. |
|
I applied the changes and fixed sources yaml also I implemented getMetricsNoLock/getSourcesNoLock to be able to use RWLock and avoid deadlock in write operations. Without it: CreateMetric acquires Lock -> Calls GetMetrics() which tries to acquire RLock() = Deadlock. Please let me know if there's a better approach. |
This PR fixes #1198