docs: state which error paths arm the connection reset

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qzqmh52NU8fB9RBQNNkJGt
This commit is contained in:
Ruben Fiszel
2026-08-24 17:04:29 +00:00
co-authored by Claude Opus 5
parent 04c063f4aa
commit 6b048ec9f7
2 changed files with 8 additions and 6 deletions
+6 -4
View File
@@ -368,10 +368,12 @@ pub mod connection_reset {
}
/// Arms the reset when an error proves a session is stuck in an aborted transaction.
/// `Error`'s `From<sqlx::Error>` and `to_anyhow` call this, which covers a query whose
/// error is converted or propagated with `?`. A caller that instead inspects the
/// `sqlx::Error` in place — formatting it into a message, matching on it — has to call
/// this itself, or a poisoned connection reported only there goes unnoticed.
/// `Error`'s `From<sqlx::Error>` and `to_anyhow` call this, so it covers `?` into a
/// `windmill_common::error::Result` and an explicit `map_err(to_anyhow)`. Everything
/// else has to call it: `?` into an `anyhow::Result` goes through anyhow's own `From`,
/// and a caller that inspects the `sqlx::Error` in place — formatting it into a
/// message, matching on it — never converts it at all. A poisoned connection reported
/// only down one of those paths goes unnoticed until something else reports it.
pub fn note_sqlx_error(err: &sqlx::Error) {
let sqlx::Error::Database(db_err) = err else {
return;
@@ -32,8 +32,8 @@ async fn poisoned_connection_is_reset_before_being_handed_out_again(db: Pool<Pos
err.as_database_error().and_then(|e| e.code()).as_deref(),
Some("25P02"),
);
// Converting the error is what arms the reset in production, where every `?` on a
// sqlx result goes through this same `From`.
// Converting the error is what arms the reset in production, for the `?` into a
// `windmill_common::error::Result` that most queries use.
let _ = Error::from(err);
sqlx::query_scalar::<_, i32>("SELECT 1")