-
Notifications
You must be signed in to change notification settings - Fork 582
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
test: Add mutex to opening PostgreSQL ports to prevent collision #389
Conversation
Codecov Report
@@ Coverage Diff @@
## main #389 +/- ##
==========================================
+ Coverage 67.92% 68.13% +0.20%
==========================================
Files 148 148
Lines 8297 8304 +7
Branches 72 72
==========================================
+ Hits 5636 5658 +22
+ Misses 2099 2088 -11
+ Partials 562 558 -4
Continue to review full report at Codecov.
|
// Pick an explicit port on the host to connect to 5432. | ||
// This is necessary so we can configure the port to only use ipv4. | ||
port, err := getFreePort() | ||
if err != nil { | ||
openPortMutex.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: Would it be safer to defer openPortMutex.Unlock()
right after acquiring the lock? Just worried we may add a new if
and forgot to unlock the mutex down the road.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had that initially but didn't want each execution to wait for the PostgreSQL instance to start up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could separate out these functions though. I'm happy to do that if you feel it'd prevent a bug in the future!
Closes #388.