[-] resolve monitoredSources race condition, fixes #1213#1223
[-] resolve monitoredSources race condition, fixes #1213#1223Mazen050 wants to merge 6 commits intocybertec-postgresql:masterfrom
monitoredSources race condition, fixes #1213#1223Conversation
monitoredSources race conditionmonitoredSources race condition, fixes #1213
pashagolub
left a comment
There was a problem hiding this comment.
It would be perfect if you can add some tests
There was a problem hiding this comment.
I'm not sure this file is somehow related to the fix
There was a problem hiding this comment.
Sorry that's my bad, I forgot to mention that this specific test failed in CI after the fix, Also it didn't fail on my machine so its related to github's CI.
There was a problem hiding this comment.
I attempted to fix it so that when you review we can see if my fix is good or we should take another approach.
Sure thing, I was actually planning on adding tests for this specific file and had some tests already written. Will add these here asap. |
|
Hello @pashagolub I have added tests increasing coverage by about 9%. Only two functions remaining with 0% coverage Also please let me know if there are any edge cases we can add tests for that are not necessarily related to coverage. |
0xgouda
left a comment
There was a problem hiding this comment.
@pashagolub, I wonder if, instead of adding additional locking overhead, we should deprecate configured_dbs and remove the writeMonitoredSources() function entirely. Almost all dashboards now rely on admin.all_distinct_dbname_metrics instead?
d2fd661 to
2c23a05
Compare
We use it in Global Health dashboards. If we can get rid of it, I will support this decision |
Fix a data race in Reaper caused by concurrent access to the shared
monitoredSourcesslice.LoadSources()updates this slice while background goroutines (Reap()loop andWriteMonitoredSources()) read it concurrently, which triggers race detector warnings.This PR protects the slice with an RWMutex and clones it before iteration to ensure safe concurrent access.
Fixes #1213