-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 between Agent.Run() and Agent.Stop() #1624
Comments
This was referenced Jun 21, 2019
pavolloffay
pushed a commit
that referenced
this issue
Jun 26, 2019
* Fix data race between Agent.Run() and Agent.Stop() We had a data race with Agent.Stop() failing if called immediately after Agent.Run() returns. The root cause of the race was that Stop() called WaitGroup.Wait() before Run() called WaitGroup.Add() for the first time which is prohibited: https://golang.org/pkg/sync/#WaitGroup.Add This change moves WaitGroup.Add() to earlier stage which guarantees that WaitGroup.Wait() will be called after that. Github issue: #1624 Testing done: Added automated tests which was failing before the bug was fixed and does not fail any more after the fix. Also verified that `make test` passes. Signed-off-by: Tigran Najaryan <[email protected]> * Fix based on PR comments Signed-off-by: Tigran Najaryan <[email protected]>
done in #1625 |
outdoorSpirit
pushed a commit
to outdoorSpirit/Go-Jag
that referenced
this issue
May 3, 2024
* Fix data race between Agent.Run() and Agent.Stop() We had a data race with Agent.Stop() failing if called immediately after Agent.Run() returns. The root cause of the race was that Stop() called WaitGroup.Wait() before Run() called WaitGroup.Add() for the first time which is prohibited: https://golang.org/pkg/sync/#WaitGroup.Add This change moves WaitGroup.Add() to earlier stage which guarantees that WaitGroup.Wait() will be called after that. Github issue: jaegertracing/jaeger#1624 Testing done: Added automated tests which was failing before the bug was fixed and does not fail any more after the fix. Also verified that `make test` passes. Signed-off-by: Tigran Najaryan <[email protected]> * Fix based on PR comments Signed-off-by: Tigran Najaryan <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirement - what kind of business use case are you trying to solve?
Agent.Stop() must not fail if called after Agent.Run() returns.
Problem - what in Jaeger blocks you from solving the requirement?
Agent.Stop() panics or shows a data race during tests.
Proposal - what do you suggest to solve the problem or improve the existing situation?
Fix the data race. Make sure Stop() waits until effects of Agent.Run() are finished or interrupts them gracefully. Alternatively make Agent.Run() synchronous so that it waits until all starting effects are complete.
The root cause of the race is that Stop() calls WaitGroup.Wait() before Run() calls WaitGroup.Add() for the first time which is prohibited: https://golang.org/pkg/sync/#WaitGroup.Add
Reproduction
Add the following test to /github.com/jaegertracing/jaeger/cmd/agent/app/agent_test.go:
and run
go test -v -race github.com/jaegertracing/jaeger/cmd/agent/app
The output shows a data race:
The text was updated successfully, but these errors were encountered: