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

fix: add commander stopping sync mechanism #352

Merged
merged 5 commits into from
Feb 20, 2025

Conversation

rogercoll
Copy link
Contributor

@rogercoll rogercoll commented Feb 18, 2025

Resolves #256

Test that generates the data race:

func TestNewSupervisor(t *testing.T) {
...

	supervisor, err := NewSupervisor(&internal.NopLogger{})
	assert.NoError(t, err)

	supervisor.Shutdown()
}

It looks like the commander struct is started in a go routine when the NewSupervisor is created. The data race happens when the commander is stopped (supervisor.Shutdown()) while being initalized (Start).

The fix adds a synchronization mechanism to prevent the commander being started if it is already being stopped.

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.29%. Comparing base (2ecac8d) to head (8f99ffa).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #352   +/-   ##
=======================================
  Coverage   78.29%   78.29%           
=======================================
  Files          25       25           
  Lines        2386     2386           
=======================================
  Hits         1868     1868           
  Misses        410      410           
  Partials      108      108           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rogercoll rogercoll marked this pull request as ready for review February 18, 2025 15:36
@rogercoll rogercoll requested a review from a team as a code owner February 18, 2025 15:36
@tigrannajaryan tigrannajaryan dismissed their stale review February 20, 2025 14:42

Comments addressed.

@tigrannajaryan tigrannajaryan merged commit fe44fcc into open-telemetry:main Feb 20, 2025
11 checks passed
@tigrannajaryan
Copy link
Member

Thanks for the fix @rogercoll

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 example supervisor
2 participants