Skip to main content

is_connection_lost

Function is_connection_lost 

Source
pub fn is_connection_lost(msg: &str) -> bool
Expand description

Classify an error message as one where the underlying connection is no longer usable and the caller should recycle it. Used to decide whether the crate::engine::Engine should be torn down and reinitialized before the next call.

Covers two distinct failure modes:

  1. Transport-level disappearance — OS broken-pipe / reset / refused plus the generic end-of-file and “connection closed” responses the PostgreSQL client produces when hyperd crashes or is killed mid-transaction.

  2. Wire-protocol desync — the hyper-client layer marks a connection desynchronized when its bounded drain exhausts the POST_ERROR_DRAIN_CAP budget without reaching ReadyForQuery or hits an I/O error mid-drain. Subsequent operations on that connection fast-fail with an ErrorKind::Connection whose message contains "desynchronized". The socket is technically still open but the wire state is corrupt and the only valid recovery is the same as #1: discard the connection and reconnect. Recognizing the signal here is what makes the mcp server’s auto-reconnect path kick in for that case instead of returning the drain-poisoned error to callers forever.