Skip to content

Commit b143dcb

Browse files
authored
Dont log disconnect from load balancer health checks (#389)
1 parent 157033a commit b143dcb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pgdog/src/frontend/listener.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//! Connection listener. Handles all client connections.
22
3+
use std::io::ErrorKind;
34
use std::net::SocketAddr;
45
use std::sync::Arc;
56

67
use crate::backend::databases::{databases, reload, shutdown};
78
use crate::config::config;
89
use crate::net::messages::BackendKeyData;
910
use crate::net::messages::{hello::SslReply, Startup};
10-
use crate::net::tls::acceptor;
11+
use crate::net::{self, tls::acceptor};
1112
use crate::net::{tweak, Stream};
1213
use crate::sighup::Sighup;
1314
use tokio::net::{TcpListener, TcpStream};
@@ -140,7 +141,19 @@ impl Listener {
140141
let tls = acceptor();
141142

142143
loop {
143-
let startup = Startup::from_stream(&mut stream).await?;
144+
let startup = match Startup::from_stream(&mut stream).await {
145+
Ok(startup) => startup,
146+
Err(net::Error::Io(io_err)) => {
147+
// Load balancers like AWS ELB use TCP to health check
148+
// targets and abruptly disconnect.
149+
if io_err.kind() == ErrorKind::ConnectionReset {
150+
return Ok(());
151+
} else {
152+
return Err(net::Error::Io(io_err).into());
153+
}
154+
}
155+
Err(err) => return Err(err.into()),
156+
};
144157

145158
match startup {
146159
Startup::Ssl => {

0 commit comments

Comments
 (0)