Skip to content

Commit 75e386e

Browse files
committed
better logging
1 parent 9375ea8 commit 75e386e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/webserver/database/connect.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,18 @@ fn on_return_to_pool(
106106
) -> BoxFuture<'_, Result<bool, sqlx::Error>> {
107107
Box::pin(async move {
108108
match conn.execute("ROLLBACK").await {
109-
Ok(r) => log::info!(
110-
"Rolled back a transaction that was left open before returning a connection to the pool. Result: {:?}",
111-
r
112-
),
109+
Ok(query_result) => {
110+
if query_result.rows_affected() > 0 {
111+
log::warn!(
112+
"Rolled back a transaction, because it was left open after a page was rendered, and it affected {} rows",
113+
query_result.rows_affected()
114+
);
115+
} else {
116+
log::trace!(
117+
"Rolled back a transaction before returning a connection to the pool"
118+
);
119+
}
120+
}
113121
Err(e) => log::trace!(
114122
"Failed to rollback before returning a connection to the pool. There was probably no transaction left open: {e:?}"
115123
),

0 commit comments

Comments
 (0)