Skip to content

PgListener::try_recv doesnt match for ConnectionReset #4014

@PonasKovas

Description

@PonasKovas

I have found these related issues/pull requests

none

Description

if matches!(
err.kind(),
io::ErrorKind::ConnectionAborted |
io::ErrorKind::UnexpectedEof |
// see ERRORS section in tcp(7) man page (https://man7.org/linux/man-pages/man7/tcp.7.html)
io::ErrorKind::TimedOut |
io::ErrorKind::BrokenPipe
) =>

Is it intentional behavior to only match these IO error kinds when deciding whether to bubble it up or try to recover by reconnecting and returning Ok(None)?

I stumbled upon this because I have a test that ensures correct behavior of my app in a specific race condition with a network failure to the DB, and on one machine it was working fine, while on another machine, with all things the same I was getting the ConnectionReset error, which resulted in PgListener::try_recv returning Err instead of Ok(None) and reconnecting, which is what I wanted.

Reproduction steps

  1. PgListener::try_recv
  2. Simulate connection failure
  3. Sometimes this returns Ok(None) (expected) and sometimes Err (unexpected)

SQLx version

master

Enabled SQLx features

postgres

Database server and version

postgres

Operating system

linux

Rust version

rustc 1.91.0-nightly (69b76df90 2025-08-23)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions