Skip to content

PgSQL: debug assert(0) instead of graceful error when backend hostname cannot be resolved (libpq connect path) #5896

Description

@renecannao

Found on branch feature/pgsql-native-backend-protocol (PR #5882) during test-infra debugging, but the code path is pre-existing (default branch dates to 23a764e, 2025-09-17).

When a backend hostname fails DNS resolution, the libpq connect path logs the error and then aborts on a debug build:

PgSQL_Connection.cpp:381:handler(): [ERROR] Failed to PQconnectStart() on 0:pgsql1...:5432 , FD (Conn:-1 , MyDS:0) , [08006] Name or service not known.
proxysql: PgSQL_Connection.cpp:1062: PG_ASYNC_ST PgSQL_Connection::handler(short int): Assertion `0' failed.
Error: signal 6
  PgSQL_Connection::handler(short)
  PgSQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED__get_connection()
  PgSQL_Session::handler_again___status_CONNECTING_SERVER(int*)

The state machine lands in the default: /* not implemented yet */ assert(0); branch of PgSQL_Connection::handler() (~:1062) after PQconnectStart fails. A misconfigured/unresolvable backend host should surface as a normal connect error (retries, error to client) — as it does in release builds where the assert compiles out — not a process abort. Since the project's TAP infra runs debug builds exclusively, any DNS hiccup kills the whole test run.

Fix direction: handle the connect-failed state explicitly in that switch instead of falling into the catch-all assert.

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