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

Use SO_REUSEADDR and SO_REUSEPORT options when creating the sql server on Unix #1830

Merged
merged 4 commits into from
Jun 16, 2023

Conversation

nicktobey
Copy link
Contributor

This prevents a transient error we've been seeing where the server sometimes fails to start, and the OS claims port already in use, even though we've already confirmed that the port is not in use prior to running dolt sql-server.

Copy link
Contributor

@fulghum fulghum left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for tackling this one for us! 🙏

server/net_listener_unix.go Show resolved Hide resolved
server/net_listener_windows.go Show resolved Hide resolved
Control: func(network, address string, c syscall.RawConn) error {
var socketErr error
err := c.Control(func(fd uintptr) {
err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

(minor) Would be nice to leave a short one sentence comment in here quickly explaining the intent of this. Would be helpful for future code readers who find this and aren't sure why it's needed. (More helpful to explain the issue we were seeing with port reuse and the hypothesis about TIME_WAIT than just rehashing what the options do, since that's easy to look up.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@nicktobey nicktobey merged commit bd0a559 into main Jun 16, 2023
@nicktobey nicktobey deleted the nicktobey/sql-server branch June 16, 2023 22:58
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.

2 participants