Skip to content

Commit 7a419f4

Browse files
committed
Revert "Require a reason when marking a server bad (#654)"
This reverts commit 4dbef49.
1 parent 54c4ad1 commit 7a419f4

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

src/client.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ where
14371437
.await
14381438
{
14391439
// We might be in some kind of error/in between protocol state
1440-
server.mark_bad(err.to_string().as_str());
1440+
server.mark_bad();
14411441
return Err(err);
14421442
}
14431443

@@ -1504,7 +1504,7 @@ where
15041504
match write_all_flush(&mut self.write, &response).await {
15051505
Ok(_) => (),
15061506
Err(err) => {
1507-
server.mark_bad(err.to_string().as_str());
1507+
server.mark_bad();
15081508
return Err(err);
15091509
}
15101510
};
@@ -1926,7 +1926,7 @@ where
19261926
Ok(_) => (),
19271927
Err(err) => {
19281928
// We might be in some kind of error/in between protocol state, better to just kill this server
1929-
server.mark_bad(err.to_string().as_str());
1929+
server.mark_bad();
19301930
return Err(err);
19311931
}
19321932
};
@@ -1993,13 +1993,11 @@ where
19931993
}
19941994
},
19951995
Err(_) => {
1996-
server.mark_bad(
1997-
format!(
1998-
"Statement timeout while talking to {:?} with user {}",
1999-
address, pool.settings.user.username
2000-
)
2001-
.as_str(),
1996+
error!(
1997+
"Statement timeout while talking to {:?} with user {}",
1998+
address, pool.settings.user.username
20021999
);
2000+
server.mark_bad();
20032001
pool.ban(address, BanReason::StatementTimeout, Some(client_stats));
20042002
error_response_terminal(&mut self.write, "pool statement timeout").await?;
20052003
Err(Error::StatementTimeout)

src/mirrors.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ impl MirroredClient {
8585
match recv_result {
8686
Ok(message) => trace!("Received from mirror: {} {:?}", String::from_utf8_lossy(&message[..]), address.clone()),
8787
Err(err) => {
88-
server.mark_bad(
89-
format!("Failed to send to mirror, Discarding message {:?}, {:?}", err, address.clone()).as_str()
90-
);
88+
server.mark_bad();
89+
error!("Failed to receive from mirror {:?} {:?}", err, address.clone());
9190
}
9291
}
9392
}
@@ -99,9 +98,8 @@ impl MirroredClient {
9998
match server.send(&BytesMut::from(&bytes[..])).await {
10099
Ok(_) => trace!("Sent to mirror: {} {:?}", String::from_utf8_lossy(&bytes[..]), address.clone()),
101100
Err(err) => {
102-
server.mark_bad(
103-
format!("Failed to receive from mirror {:?} {:?}", err, address.clone()).as_str()
104-
);
101+
server.mark_bad();
102+
error!("Failed to send to mirror, Discarding message {:?}, {:?}", err, address.clone())
105103
}
106104
}
107105
}

src/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ impl ConnectionPool {
871871
}
872872

873873
// Don't leave a bad connection in the pool.
874-
server.mark_bad("failed health check");
874+
server.mark_bad();
875875

876876
self.ban(address, BanReason::FailedHealthCheck, Some(client_info));
877877
false

src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,8 +1279,8 @@ impl Server {
12791279
}
12801280

12811281
/// Indicate that this server connection cannot be re-used and must be discarded.
1282-
pub fn mark_bad(&mut self, reason: &str) {
1283-
error!("Server {:?} marked bad, reason: {}", self.address, reason);
1282+
pub fn mark_bad(&mut self) {
1283+
error!("Server {:?} marked bad", self.address);
12841284
self.bad = true;
12851285
}
12861286

0 commit comments

Comments
 (0)