Browse Source

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
commit
66b0aa3b45
  1. 2
      discovery/file/file.go

2
discovery/file/file.go

@ -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