nerdswords / yet-another-cloudwatch-exporter

Prometheus exporter for AWS CloudWatch - Discovers services through AWS tags, gets CloudWatch metrics data and provides them as Prometheus metrics with AWS tags as labels
Apache License 2.0
981 stars 334 forks source link

WARNING: DATA RACE (while doing first scraping) #207

Closed jylitalo closed 3 years ago

jylitalo commented 4 years ago

I compiled yace with -race option on my local machine (head more or less identical with 88f0488ca94f66d394c71d48353e14462f2da733), started it up on one terminal and issued curl http://localhost:5000/metrics on another terminal. When I look into main.go, all the line numbers point to registry handling. Considering that yace is supposed to be running long sessions at a time, this probably is not an issue, but worth noting. A fix would probably require that process must wait until the first scraping is completed.


==================
WARNING: DATA RACE
Read at 0x00c0000be358 by goroutine 67:
  main.main.func3()
      /Users/jylitalo/Yleisradio/yet-another-cloudwatch-exporter/main.go:152 +0xaa
  net/http.HandlerFunc.ServeHTTP()
      /usr/local/Cellar/go/1.13.4/libexec/src/net/http/server.go:2007 +0x51
  net/http.(*ServeMux).ServeHTTP()
      /usr/local/Cellar/go/1.13.4/libexec/src/net/http/server.go:2387 +0x288
  net/http.serverHandler.ServeHTTP()
      /usr/local/Cellar/go/1.13.4/libexec/src/net/http/server.go:2802 +0xce
  net/http.(*conn).serve()
      /usr/local/Cellar/go/1.13.4/libexec/src/net/http/server.go:1890 +0x837

Previous write at 0x00c0000be358 by goroutine 9:
  main.main.func1()
      /Users/jylitalo/Yleisradio/yet-another-cloudwatch-exporter/main.go:129 +0x209

Goroutine 67 (running) created at:
  net/http.(*Server).Serve()
      /usr/local/Cellar/go/1.13.4/libexec/src/net/http/server.go:2927 +0x5be
  net/http.(*Server).ListenAndServe()
      /usr/local/Cellar/go/1.13.4/libexec/src/net/http/server.go:2825 +0x102
  main.main()
      /usr/local/Cellar/go/1.13.4/libexec/src/net/http/server.go:3080 +0x74f

Goroutine 9 (running) created at:
  main.main()
      /Users/jylitalo/Yleisradio/yet-another-cloudwatch-exporter/main.go:124 +0x888
==================
thomaspeitz commented 3 years ago

Closing this. Feel free to PR a fix.

I won't work on this one as long as not more users have problems with this behaviour.