Skip to main content

check_postgres_server_available

Function check_postgres_server_available 

Source
pub async fn check_postgres_server_available(
    args: &PostgresArgs,
) -> Result<(), TargetError>
Expand description

Probes a PostgreSQL server for connectivity and verifies the configured table is readable.

Used by both the admin validation flow (pre-flight before persisting a target) and PostgresTarget::init() (runtime startup check). The probe is strictly read-only:

  1. Build a deadpool pool from args (cheap, no actual connection yet).
  2. Check out a single connection.
  3. Run SELECT 1 to confirm the credentials work.
  4. Run SELECT 1 FROM <schema>.<table> LIMIT 0 to confirm the relation exists and the user has read permission. LIMIT 0 ensures no rows are actually returned and no DML side effects occur.

The whole flow is wrapped in an 8s tokio::time::timeout so a stuck DNS resolver or TLS handshake cannot exhaust the admin layer’s outer 10s timeout.