Skip to content

Accurate log messages #425

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

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,10 @@ impl ConnectionPool {
{
Ok(conn) => conn,
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));
address.stats.error();
client_stats.idle();
Expand Down Expand Up @@ -717,7 +720,7 @@ impl ConnectionPool {
// Health check failed.
Err(err) => {
error!(
"Banning instance {:?} because of failed health check, {:?}",
"Failed health check on instance {:?}, error: {:?}",
address, err
);
}
Expand All @@ -726,7 +729,7 @@ impl ConnectionPool {
// Health check timed out.
Err(err) => {
error!(
"Banning instance {:?} because of health check timeout, {:?}",
"Health check timeout on instance {:?}, error: {:?}",
address, err
);
}
Expand All @@ -748,13 +751,16 @@ impl ConnectionPool {
return;
}

error!("Banning instance {:?}, reason: {:?}", address, reason);

let now = chrono::offset::Utc::now().naive_utc();
let mut guard = self.banlist.write();
error!("Banning {:?}", address);

if let Some(client_info) = client_info {
client_info.ban_error();
address.stats.error();
}

guard[address.shard].insert(address.clone(), (reason, now));
}

Expand Down
22 changes: 16 additions & 6 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,10 @@ impl Server {
Ok(())
}
Err(err) => {
error!("Terminating server because of: {:?}", err);
error!(
"Terminating server {:?} because of: {:?}",
self.address, err
);
self.bad = true;
Err(err)
}
Expand All @@ -720,7 +723,10 @@ impl Server {
let mut message = match read_message(&mut self.stream).await {
Ok(message) => message,
Err(err) => {
error!("Terminating server because of: {:?}", err);
error!(
"Terminating server {:?} because of: {:?}",
self.address, err
);
self.bad = true;
return Err(err);
}
Expand Down Expand Up @@ -1135,14 +1141,18 @@ impl Drop for Server {
_ => debug!("Dirty shutdown"),
};

// Should not matter.
self.bad = true;

let now = chrono::offset::Utc::now().naive_utc();
let duration = now - self.connected_at;

let message = if self.bad {
"Server connection terminated"
} else {
"Server connection closed"
};

info!(
"Server connection closed {:?}, session duration: {}",
"{} {:?}, session duration: {}",
message,
self.address,
crate::format_duration(&duration)
);
Expand Down