Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data race causing incorrect values for solr_up metric #17

Open
Izbitzer opened this issue May 2, 2019 · 1 comment
Open

Data race causing incorrect values for solr_up metric #17

Izbitzer opened this issue May 2, 2019 · 1 comment

Comments

@Izbitzer
Copy link

Izbitzer commented May 2, 2019

Running the following simple bash script causes the first request to get a value of 0 for the solr_up metric:

curl -s localhost:9231/metrics &                                                                                        
curl -s  localhost:9231/metrics &  

It appears to be a data race, as changing line 228 of exporter.go to the following fixes it:

defer func() {
    ch <- e.up
    time.Sleep(1 * time.Millisecond)
}()

I don't know Go well enough to know what a proper fix might be, but from what I can tell it appears that the second metrics request enters the Collect function and resets the value of e.up before the first one is received and processed on the other side of the channel.

Izbitzer added a commit to Izbitzer/prometheus-solr-exporter that referenced this issue May 2, 2019
This should fix noony#17

If two requests to /metric were made simultaneously the "up" metric
would be incorrectly returned as 0 for the first request
@Izbitzer
Copy link
Author

Izbitzer commented May 2, 2019

I made a fix which I believe should work. Though as I mentioned, I am far from a Go expert, so could be that it's not an optimal solution.

Izbitzer added a commit to Izbitzer/prometheus-solr-exporter that referenced this issue May 6, 2019
This should fix noony#17

If two requests to /metric were made simultaneously the "up" metric
would be incorrectly returned as 0 for the first request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant