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

Make caser a local varialbe, not a global one. #927

Merged
merged 1 commit into from
Jun 17, 2022

Conversation

mem
Copy link
Contributor

@mem mem commented Jun 13, 2022

The cases.Caser returned by calling cases.Title cannot be shared among
goroutines. This might happen when Prometheus tries to scrape multiple
targets at the same time. From the docs:

A Caser may be stateful and should therefore not be shared between
goroutines.

Fixes: #922

Signed-off-by: Marcelo E. Magallon [email protected]

@mem mem requested a review from roidelapluie June 13, 2022 23:23
The cases.Caser returned by calling cases.Title *cannot* be shared among
goroutines. This might happen when Prometheus tries to scrape multiple
targets at the same time. From the docs:

A Caser may be stateful and should therefore not be shared between
goroutines.

Fixes: #922

Signed-off-by: Marcelo E. Magallon <[email protected]>
@mem mem force-pushed the mem/make_caser_local branch from a0a6364 to 19016d2 Compare June 13, 2022 23:28
Copy link
Member

@electron0zero electron0zero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

mem added a commit to grafana/synthetic-monitoring-agent that referenced this pull request Jun 14, 2022
There's an open PR in BBE to fix an issue with reusing a
golang.org/x/text/cases/Caser:

prometheus/blackbox_exporter#927

Signed-off-by: Marcelo E. Magallon <[email protected]>
mem added a commit to grafana/synthetic-monitoring-agent that referenced this pull request Jun 14, 2022
There's an open PR in BBE to fix an issue with reusing a
golang.org/x/text/cases/Caser:

prometheus/blackbox_exporter#927

Signed-off-by: Marcelo E. Magallon <[email protected]>
//
// A Caser may be stateful and should therefore not be shared between goroutines.
//
// Issue: https://github.com/prometheus/blackbox_exporter/issues/922
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is necessary to point to the gh issue here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt it was necessary to keep the reference close to the code because the original version is what I would have written, too. The wording in the docs, "a Caser may", sounds like if that were the actual case, the individual Caser implementations would spell that out. Given that in this particular instance there no such note, I would have assumed that this Caser is not stateful.

Thanks for the review and merging this!

@roidelapluie roidelapluie merged commit e38d38d into master Jun 17, 2022
@roidelapluie roidelapluie deleted the mem/make_caser_local branch June 17, 2022 12:22
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

Successfully merging this pull request may close these issues.

Data race in ProbeHTTP
3 participants