You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the ProviderSender#Start is called to run with more than one goroutine then a race condition occurs due to the shared variable ProviderSender#prevError.
Steps to Reproduce
Write a test or edit an existing one to call ProviderSender#Start with load options having LoadOptions#Parallel value greater than 1. Example:
==================
WARNING: DATA RACE
Write at 0x00c000466160 by goroutine 59:
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed.(*ProviderSender).generateTrace()
/Users/lahsivjar/Projects/elastic/opentelemetry-collector-contrib/testbed/testbed/load_generator.go:250 +0x2d0
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed.(*ProviderSender).generate.func1()
/Users/lahsivjar/Projects/elastic/opentelemetry-collector-contrib/testbed/testbed/load_generator.go:218 +0x1f0
Previous write at 0x00c000466160 by goroutine 60:
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed.(*ProviderSender).generateTrace()
/Users/lahsivjar/Projects/elastic/opentelemetry-collector-contrib/testbed/testbed/load_generator.go:250 +0x2d0
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed.(*ProviderSender).generate.func1()
/Users/lahsivjar/Projects/elastic/opentelemetry-collector-contrib/testbed/testbed/load_generator.go:218 +0x1f0
Goroutine 59 (running) created at:
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed.(*ProviderSender).generate()
/Users/lahsivjar/Projects/elastic/opentelemetry-collector-contrib/testbed/testbed/load_generator.go:209 +0x23c
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed.(*ProviderSender).Start.func2()
/Users/lahsivjar/Projects/elastic/opentelemetry-collector-contrib/testbed/testbed/load_generator.go:119 +0x34
Goroutine 60 (running) created at:
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed.(*ProviderSender).generate()
/Users/lahsivjar/Projects/elastic/opentelemetry-collector-contrib/testbed/testbed/load_generator.go:209 +0x23c
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed.(*ProviderSender).Start.func2()
/Users/lahsivjar/Projects/elastic/opentelemetry-collector-contrib/testbed/testbed/load_generator.go:119 +0x34
==================
Additional context
Possible solution: Make prevError local to the generate{Log,Metrics,Trace} and remove it from ProviderSender -- not sure if I am missing something here but that should be enough. If we require the prevError to be a field in the ProviderSender then we can use atomic.Value.
The text was updated successfully, but these errors were encountered:
Fixes a race condition in testbed's default load generator
(`ProviderSender`). The fix changes the behavior of how logging works
for the `ProviderSender`. Before this PR, the code will try to log
errors if the previous error is not the same and it would try to do this
across goroutines. Now, each error will be logged if the previous error
is not the same for each goroutine.
Alternatively, we can also build a logger using bloom filter to try to
log each error once though I am not sure if that would be required. This
PR offers a quick fix while keeping the behavior reasonably close to the
current behavior.
Closes#32326
**Link to tracking Issue:**
#32326
**Testing:** Follow the steps in the tracking issue.
Component(s)
testbed
What happened?
Description
If the
ProviderSender#Start
is called to run with more than one goroutine then a race condition occurs due to the shared variableProviderSender#prevError
.Steps to Reproduce
ProviderSender#Start
with load options havingLoadOptions#Parallel
value greater than1
. Example:make test
orgo test -v -race ./...
Expected Result
No race condition and the tests pass.
Actual Result
Race conditions found by the race-detector.
Collector version
v0.98.0
Environment information
Environment
OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")
OpenTelemetry Collector configuration
No response
Log output
Additional context
Possible solution: Make
prevError
local to thegenerate{Log,Metrics,Trace}
and remove it fromProviderSender
-- not sure if I am missing something here but that should be enough. If we require theprevError
to be a field in theProviderSender
then we can useatomic.Value
.The text was updated successfully, but these errors were encountered: