-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[client] Metadata
is not thread safe
#9594
Comments
Is it expected that this feature NOT be thread-safe and that users (like the extension) should implement protection around |
I believe it should be made thread safe. The initial assumption I had back then was that receivers would write and other components would read, meaning that only one part would write at any given time. I think the optimization that causes the write was added later and a lock should have been added there, given the initial assumption changed. |
As @bogdandrutu pointed out, the issue is happening specifically because of |
**Description:** Fixes a bug where `Get` was not thread safe. **Link to tracking Issue:** <Issue number if applicable> Closes #9594 **Testing:** <Describe what testing was performed and which tests were added.> Tested locally
Describe the bug
Related to open-telemetry/opentelemetry-collector-contrib#31289
I believe there is a bug in
Metadata.Get
when accessed by multiple threads.If the
Metadata
struct is added to a context that is then shared between multiple exporters and those exporters attempt aGet
at the same time the collector will panic withfatal error: concurrent map writes
.We are seeing this happen right now with the headerssetterextension. The extension is telling the exporters to grab details out of the context, but it is the same context used between all the exporters in the pipeline.
Code that I suspect is not thread safe:
opentelemetry-collector/client/client.go
Lines 150 to 171 in 59b45a5
Steps to reproduce
What did you expect to see?
No crashes, multiple exporters could extract from the same context
What did you see instead?
Panic with
fatal error: concurrent map writes
What version did you use?
Latest
The text was updated successfully, but these errors were encountered: