-
Notifications
You must be signed in to change notification settings - Fork 599
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
fix(pgwire): allow configuring tcp keepalive idle time #18136
Conversation
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
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. It seems to be related to the DBT EOF error.
src/utils/pgwire/src/net.rs
Outdated
{ | ||
let r = socket2::SockRef::from(&stream); | ||
let ka = socket2::TcpKeepalive::new().with_time(Duration::from_secs(300)); | ||
r.set_tcp_keepalive(&ka)?; | ||
} |
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.
Interesting. Is this a hack or a common usage of socket2
?
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 think it's the common usage and the only way for setting these extra parameters until tokio-rs/tokio#3082 is addressed.
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
What about cp to 2.0? |
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
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!
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
It's common for an SQL statement not returning any data from the pgwire server for a long time (typically when executing DDL). If the connection is proxied through a load balancer, the LB may consider the connection idle and drop it unexpectedly.
To resolve this issue, we may set the tcp keepalive idle time to a lower value. Here we take a reference to the value in AWS ELB, which is 350 seconds. Note that this can be done in any place dealing with the connection, but doing it on the pgwire server eliminates the need for any additional configuration.
The value is configurable through CLI args and defaults to 300 seconds.
FYI, the default keepalive idle time is decided by the operating system, typically 2 hours.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.