-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: improved socket error logging for connection diagnostics #5062
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
base: main
Are you sure you want to change the base?
Conversation
28f8e9b
to
3279654
Compare
1a6f6c2
to
4385fd8
Compare
4385fd8
to
9f7ee25
Compare
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.
Have you tried killing master/replica in the middle of replication and see what is printed?
src/facade/socket_utils.cc
Outdated
|
||
auto tcp_info = io::ReadTcpInfo(sock_stat.st_ino); | ||
if (!tcp_info) { | ||
auto tcp6_info = io::ReadTcp6Info(sock_stat.st_ino); |
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.
before trying tcp6, you can get socket family:
int get_socket_family(int fd) {
struct sockaddr_storage ss;
socklen_t len = sizeof(ss);
if (getsockname(fd, (struct sockaddr *)&ss, &len) == -1) {
return -1; // Indicate an error
}
return ss.ss_family;
}
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.
fixed
src/server/common.cc
Outdated
|
||
// Add additional information about the reason for cancellation, if possible | ||
// Possible to extract from system errors or context | ||
std::error_code sys_err = std::error_code(errno, std::system_category()); |
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.
have you actually seen that this code helps?
we do not rely on errno, because iouring does not use 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.
removed
Restarting master:
Restarting replica:
|
Fixes: #5041
This implementation enhances error diagnostics when replica connections fail by implementing a utility function that extracts and formats detailed TCP socket information from /proc/net/tcp and /proc/net/tcp6 on Linux systems.
The function converts raw socket data into a human-readable format with proper TCP state names and formatted IP addresses. It's integrated with Replica, Connection, and Migration components to provide better context during connection failures.