mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-23 01:16:30 +00:00
Compare commits
3 Commits
mostafa_ad
...
levkk-max-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a419f40ea | ||
|
|
54c4ad140d | ||
|
|
190e32ae85 |
@@ -699,7 +699,7 @@ where
|
|||||||
res.put(row_description(&columns));
|
res.put(row_description(&columns));
|
||||||
|
|
||||||
for (_, client) in new_map {
|
for (_, client) in new_map {
|
||||||
let max_wait = client.wait_start.load(Ordering::Relaxed);
|
let max_wait = client.max_wait_time.load(Ordering::Relaxed);
|
||||||
let row = vec![
|
let row = vec![
|
||||||
format!("{:#010X}", client.client_id()),
|
format!("{:#010X}", client.client_id()),
|
||||||
client.pool_name(),
|
client.pool_name(),
|
||||||
|
|||||||
@@ -1437,7 +1437,7 @@ where
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
// We might be in some kind of error/in between protocol state
|
// We might be in some kind of error/in between protocol state
|
||||||
server.mark_bad(err.to_string().as_str());
|
server.mark_bad();
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1504,7 +1504,7 @@ where
|
|||||||
match write_all_flush(&mut self.write, &response).await {
|
match write_all_flush(&mut self.write, &response).await {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
server.mark_bad(err.to_string().as_str());
|
server.mark_bad();
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1926,7 +1926,7 @@ where
|
|||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// We might be in some kind of error/in between protocol state, better to just kill this server
|
// We might be in some kind of error/in between protocol state, better to just kill this server
|
||||||
server.mark_bad(err.to_string().as_str());
|
server.mark_bad();
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1993,13 +1993,11 @@ where
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
server.mark_bad(
|
error!(
|
||||||
format!(
|
"Statement timeout while talking to {:?} with user {}",
|
||||||
"Statement timeout while talking to {:?} with user {}",
|
address, pool.settings.user.username
|
||||||
address, pool.settings.user.username
|
|
||||||
)
|
|
||||||
.as_str(),
|
|
||||||
);
|
);
|
||||||
|
server.mark_bad();
|
||||||
pool.ban(address, BanReason::StatementTimeout, Some(client_stats));
|
pool.ban(address, BanReason::StatementTimeout, Some(client_stats));
|
||||||
error_response_terminal(&mut self.write, "pool statement timeout").await?;
|
error_response_terminal(&mut self.write, "pool statement timeout").await?;
|
||||||
Err(Error::StatementTimeout)
|
Err(Error::StatementTimeout)
|
||||||
|
|||||||
@@ -85,9 +85,8 @@ impl MirroredClient {
|
|||||||
match recv_result {
|
match recv_result {
|
||||||
Ok(message) => trace!("Received from mirror: {} {:?}", String::from_utf8_lossy(&message[..]), address.clone()),
|
Ok(message) => trace!("Received from mirror: {} {:?}", String::from_utf8_lossy(&message[..]), address.clone()),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
server.mark_bad(
|
server.mark_bad();
|
||||||
format!("Failed to send to mirror, Discarding message {:?}, {:?}", err, address.clone()).as_str()
|
error!("Failed to receive from mirror {:?} {:?}", err, address.clone());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,9 +98,8 @@ impl MirroredClient {
|
|||||||
match server.send(&BytesMut::from(&bytes[..])).await {
|
match server.send(&BytesMut::from(&bytes[..])).await {
|
||||||
Ok(_) => trace!("Sent to mirror: {} {:?}", String::from_utf8_lossy(&bytes[..]), address.clone()),
|
Ok(_) => trace!("Sent to mirror: {} {:?}", String::from_utf8_lossy(&bytes[..]), address.clone()),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
server.mark_bad(
|
server.mark_bad();
|
||||||
format!("Failed to receive from mirror {:?} {:?}", err, address.clone()).as_str()
|
error!("Failed to send to mirror, Discarding message {:?}, {:?}", err, address.clone())
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -871,7 +871,7 @@ impl ConnectionPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't leave a bad connection in the pool.
|
// Don't leave a bad connection in the pool.
|
||||||
server.mark_bad("failed health check");
|
server.mark_bad();
|
||||||
|
|
||||||
self.ban(address, BanReason::FailedHealthCheck, Some(client_info));
|
self.ban(address, BanReason::FailedHealthCheck, Some(client_info));
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -1279,8 +1279,8 @@ impl Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Indicate that this server connection cannot be re-used and must be discarded.
|
/// Indicate that this server connection cannot be re-used and must be discarded.
|
||||||
pub fn mark_bad(&mut self, reason: &str) {
|
pub fn mark_bad(&mut self) {
|
||||||
error!("Server {:?} marked bad, reason: {}", self.address, reason);
|
error!("Server {:?} marked bad", self.address);
|
||||||
self.bad = true;
|
self.bad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ impl ClientStats {
|
|||||||
/// Reports a client is done querying the server and is no longer assigned a server connection
|
/// Reports a client is done querying the server and is no longer assigned a server connection
|
||||||
pub fn idle(&self) {
|
pub fn idle(&self) {
|
||||||
self.state.store(ClientState::Idle, Ordering::Relaxed);
|
self.state.store(ClientState::Idle, Ordering::Relaxed);
|
||||||
self.wait_start.store(0, Ordering::Relaxed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reports a client is waiting for a connection
|
/// Reports a client is waiting for a connection
|
||||||
@@ -125,7 +124,6 @@ impl ClientStats {
|
|||||||
/// Reports a client is done waiting for a connection and is about to query the server.
|
/// Reports a client is done waiting for a connection and is about to query the server.
|
||||||
pub fn active(&self) {
|
pub fn active(&self) {
|
||||||
self.state.store(ClientState::Active, Ordering::Relaxed);
|
self.state.store(ClientState::Active, Ordering::Relaxed);
|
||||||
self.wait_start.store(0, Ordering::Relaxed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reports a client has failed to obtain a connection from a connection pool
|
/// Reports a client has failed to obtain a connection from a connection pool
|
||||||
|
|||||||
Reference in New Issue
Block a user