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

unit-race: fix race condition in unit tests #73

Merged
merged 3 commits into from
Mar 28, 2022

Conversation

guggero
Copy link
Member

@guggero guggero commented Mar 25, 2022

Fixes #71.

Turns out the problem was the histogram metrics for Prometheus added recently. They aren't concurrency safe. Since we don't start multiple instances of Aperture within the same process in production, we should never hit that outside of race unit tests.

We also move over to GitHub Actions because Travis sucks.

@guggero guggero requested a review from ellemouton March 25, 2022 12:22
@guggero
Copy link
Member Author

guggero commented Mar 25, 2022

Okay, weird, the one race condition is still there. Didn't happen locally with go 1.16.3 but happens on GitHub with go 1.17.8. Trying out a few things.

@guggero guggero force-pushed the race-fix branch 2 times, most recently from 0415aed to 19f91ae Compare March 25, 2022 13:14
To avoid running into an issue in the race unit test with the Prometheus
histogram metrics that aren't concurrency safe, we don't register any of
them if Prometheus isn't enabled in the first place.
This shouldn't be an issue in production, since we don't start multiple
instances of Aperture _within the same process_ at the same time.
There's a race condition in the h2_bundle.go of go 1.16.10 and later. The
issue golang/go#51799 mentions that this might
be fixed in go 1.19, so we'll need to wait for that.
We make sure we build our docker images with go 1.16.9 to not run into
the issue in the wild.
@guggero
Copy link
Member Author

guggero commented Mar 25, 2022

Yayy, I was able to fix the tests by pinning everything to go 1.16.9 🎉

Copy link
Member

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Amazing!!! 🔥

@guggero guggero requested a review from carlaKC March 25, 2022 13:36
Copy link
Contributor

@positiveblue positiveblue left a comment

Choose a reason for hiding this comment

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

Just of the travis migrations this PR deserves a big approve 🎉 🎉

(I guess that you meant that you uploaded go to version 1.16.9 instead of 1.18.9 ?)

@guggero guggero merged commit 4a2632d into lightninglabs:master Mar 28, 2022
@guggero guggero deleted the race-fix branch March 28, 2022 07:25
@guggero
Copy link
Member Author

guggero commented Mar 28, 2022

Just of the travis migrations this PR deserves a big approve tada tada

(I guess that you meant that you uploaded go to version 1.16.9 instead of 1.18.9 ?)

Yeah, typo :) Fixed the comment. Thanks for the review!

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.

unit-race: tests broken in go 1.16
4 participants