Poorly behaved client fix (#65)

* Poorly behaved client fix

* yes officer

* fix tests

* no useless rescue

* Looks ok
This commit is contained in:
Lev Kokotov
2022-05-09 11:09:22 -05:00
committed by GitHub
parent df85139281
commit ccbca66e7a
4 changed files with 43 additions and 2 deletions

View File

@@ -359,7 +359,8 @@ impl Client {
// Clean up the server and re-use it.
// This prevents connection thrashing by bad clients.
if server.in_transaction() {
server.query("ROLLBACK; DISCARD ALL;").await?;
server.query("ROLLBACK").await?;
server.query("DISCARD ALL").await?;
}
return Err(err);
@@ -429,7 +430,8 @@ impl Client {
// Pgbouncer closes the connection which leads to
// connection thrashing when clients misbehave.
if server.in_transaction() {
server.query("ROLLBACK; DISCARD ALL;").await?;
server.query("ROLLBACK").await?;
server.query("DISCARD ALL").await?;
}
return Ok(());