-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
server: try avoid the "address already in use" error #8842
Conversation
Replace defer l.Close() with l.Close() to shutdown the listener as fast as possible to avoid the "bind: address already in use" error that so often occurs in CI build. From: phayes/freeport#8 Reference: #6671
Codecov Report
@@ Coverage Diff @@
## master #8842 +/- ##
=======================================
Coverage 59.15% 59.15%
=======================================
Files 570 570
Lines 31770 31768 -2
=======================================
Hits 18793 18793
+ Misses 10776 10774 -2
Partials 2201 2201
|
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.
All tests seem to pass on CI, so I'm okay with this.
panic(err) | ||
} | ||
if err := l.Close(); err != nil { | ||
return "", "", fmt.Errorf("couldn't close the listener: %w", err) |
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.
should we wrap it?
sdkerrors.Wrap(sdkerrors.ErrIO, ....)
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.
Yes, sure, good one. I'm not just yet sure this PR actually fixes anything at all. I warmly welcome suggestions - and I'm CC'ing @odeke-em too.
If this does not improve anything, I'd just close it.
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.
The PR has good improvement - it removes panic
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.
[thinking aloud]
shouldn't I call Close() as the very last statement of this function before returning?
[/thinking aloud]
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.
Yup, @robert-zaremba got a great point that we should wrap it, for consistency with other errors.
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.
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=ec354e38040bcfe1aaad394e01ac272806277301 |
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=925c74779d524a63b15eb724f5b6b961 |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=850135918558f7c43fb24fb86564c9454dcf66ea |
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.
LGTM, thank you @alessio! Good start for now and thanks for referencing that issue that I flagged a while ago. Later on would be nice for us to dig into the syscall package and figure out the calls to get an available address and bind to it then pass in a listener to the code that needs it. Currently still closing is at the mercy of the OS reusing file descriptors at a speed. Thanks again, and my apologies for the late reply.
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=8877c91f9134468ca74f5b70e148324f |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=d02a39739be4850548c8c157660cb952b83e2ac7 |
Replace defer l.Close() with l.Close() to shutdown the listener
as fast as possible to avoid the "bind: address already in use"
error that so often occurs in CI build.
From: phayes/freeport#8
Reference: #6671
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes