Fixed race condition in map iteration and map write in Discovery (#3735) (#3738)

* Fixed concurrent map iteration and map write in Discovery (#3735)

* discovery: Changed Lock to RLock in Collect
pull/3760/head
Ganesh Vernekar 7 years ago committed by Goutham Veeramachaneni
parent 8b20cb1e8d
commit 66b0aa3b45

@ -96,9 +96,11 @@ func (t *TimestampCollector) Collect(ch chan<- prometheus.Metric) {
uniqueFiles := make(map[string]float64)
t.lock.RLock()
for fileSD := range t.discoverers {
fileSD.lock.RLock()
for filename, timestamp := range fileSD.timestamps {
uniqueFiles[filename] = timestamp
}
fileSD.lock.RUnlock()
}
t.lock.RUnlock()
for filename, timestamp := range uniqueFiles {

Loading…
Cancel
Save