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 data race in dynamic plugin registry tests #12554

Merged
merged 2 commits into from
Apr 14, 2022
Merged

Conversation

tgross
Copy link
Member

@tgross tgross commented Apr 12, 2022

These tests have a data race where the test assertion is reading a
value that's being set in the listenFunc goroutines that are
subscribing to registry update events. Move the assertion into the
subscribing goroutine to remove the race. This bug was discovered
in #12098 but does not impact production Nomad code.

Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

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

Approving because even if my comments are valid I don't need to re-review after any fixes.

Thanks for doing this!

for {
select {
case <-ctx.Done():
t.Fail()
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps use t.Errorf here? It's still safe for concurrent use (unlike Fatalf and FailNow) but would allow you to output a hint as to what went wrong.

At a glance I'm not sure what a failure here means other than "an unexpected thing happened," but I'm also not familiar with these tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call. The original tests were just "we didn't finish" and that's not very helpful to repeat when fixing the test 😁

Comment on lines 73 to 76
rcv1 = true
if rcv1 {
return
}
Copy link
Member

Choose a reason for hiding this comment

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

rcv1 seems like a noop. Can this be replaced with return?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, yup. Copypasta from the previous test. Will fix.

These tests have a data race where the test assertion is reading a
value that's being set in the `listenFunc` goroutines that are
subscribing to registry update events. Move the assertion into the
subscribing goroutine to remove the race. This bug was discovered
in #12098 but does not impact production Nomad code.
Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

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

LGTM! (and sorry I missed this 😞 )

@tgross tgross merged commit d2aab5d into main Apr 14, 2022
@tgross tgross deleted the b-registry-data-race branch April 14, 2022 18:55
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme/testing Test related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants