mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-23 01:16:30 +00:00
Accurate log messages (#425)
This commit is contained in:
14
src/pool.rs
14
src/pool.rs
@@ -641,7 +641,10 @@ impl ConnectionPool {
|
|||||||
{
|
{
|
||||||
Ok(conn) => conn,
|
Ok(conn) => conn,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Banning instance {:?}, error: {:?}", address, err);
|
error!(
|
||||||
|
"Connection checkout error for instance {:?}, error: {:?}",
|
||||||
|
address, err
|
||||||
|
);
|
||||||
self.ban(address, BanReason::FailedCheckout, Some(client_stats));
|
self.ban(address, BanReason::FailedCheckout, Some(client_stats));
|
||||||
address.stats.error();
|
address.stats.error();
|
||||||
client_stats.idle();
|
client_stats.idle();
|
||||||
@@ -717,7 +720,7 @@ impl ConnectionPool {
|
|||||||
// Health check failed.
|
// Health check failed.
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(
|
error!(
|
||||||
"Banning instance {:?} because of failed health check, {:?}",
|
"Failed health check on instance {:?}, error: {:?}",
|
||||||
address, err
|
address, err
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -726,7 +729,7 @@ impl ConnectionPool {
|
|||||||
// Health check timed out.
|
// Health check timed out.
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(
|
error!(
|
||||||
"Banning instance {:?} because of health check timeout, {:?}",
|
"Health check timeout on instance {:?}, error: {:?}",
|
||||||
address, err
|
address, err
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -748,13 +751,16 @@ impl ConnectionPool {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error!("Banning instance {:?}, reason: {:?}", address, reason);
|
||||||
|
|
||||||
let now = chrono::offset::Utc::now().naive_utc();
|
let now = chrono::offset::Utc::now().naive_utc();
|
||||||
let mut guard = self.banlist.write();
|
let mut guard = self.banlist.write();
|
||||||
error!("Banning {:?}", address);
|
|
||||||
if let Some(client_info) = client_info {
|
if let Some(client_info) = client_info {
|
||||||
client_info.ban_error();
|
client_info.ban_error();
|
||||||
address.stats.error();
|
address.stats.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
guard[address.shard].insert(address.clone(), (reason, now));
|
guard[address.shard].insert(address.clone(), (reason, now));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -705,7 +705,10 @@ impl Server {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Terminating server because of: {:?}", err);
|
error!(
|
||||||
|
"Terminating server {:?} because of: {:?}",
|
||||||
|
self.address, err
|
||||||
|
);
|
||||||
self.bad = true;
|
self.bad = true;
|
||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
@@ -720,7 +723,10 @@ impl Server {
|
|||||||
let mut message = match read_message(&mut self.stream).await {
|
let mut message = match read_message(&mut self.stream).await {
|
||||||
Ok(message) => message,
|
Ok(message) => message,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Terminating server because of: {:?}", err);
|
error!(
|
||||||
|
"Terminating server {:?} because of: {:?}",
|
||||||
|
self.address, err
|
||||||
|
);
|
||||||
self.bad = true;
|
self.bad = true;
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
@@ -1135,14 +1141,18 @@ impl Drop for Server {
|
|||||||
_ => debug!("Dirty shutdown"),
|
_ => debug!("Dirty shutdown"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Should not matter.
|
|
||||||
self.bad = true;
|
|
||||||
|
|
||||||
let now = chrono::offset::Utc::now().naive_utc();
|
let now = chrono::offset::Utc::now().naive_utc();
|
||||||
let duration = now - self.connected_at;
|
let duration = now - self.connected_at;
|
||||||
|
|
||||||
|
let message = if self.bad {
|
||||||
|
"Server connection terminated"
|
||||||
|
} else {
|
||||||
|
"Server connection closed"
|
||||||
|
};
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"Server connection closed {:?}, session duration: {}",
|
"{} {:?}, session duration: {}",
|
||||||
|
message,
|
||||||
self.address,
|
self.address,
|
||||||
crate::format_duration(&duration)
|
crate::format_duration(&duration)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user