block/buzz · error

connect admin

Error message

connect admin

What it means

Panic from `.expect("connect admin")` on `PgPool::connect(&admin_url().await)` in the ignored Postgres-gated test `channel_roster_fence_behavior_verification_detects_inert_function`. The admin connection is required to create a scratch database; Err means Postgres refused or timed out.

Source

Thrown at crates/buzz-db/src/store/channel_members.rs:3023

            "failed startup gate must not publish a roster"
        );

        migration::run_migrations(&pool)
            .await
            .expect("apply migration 0032");
        db.verify_channel_roster_fence()
            .await
            .expect("0032 must open the startup gate");

        drop_scratch_db(&admin, pool, &scratch_name).await;
    }

    #[tokio::test]
    #[ignore = "requires Postgres"]
    async fn channel_roster_fence_behavior_verification_detects_inert_function() {
        let admin = PgPool::connect(&admin_url().await)
            .await
            .expect("connect admin");
        let (pool, scratch_name) = create_scratch_db(&admin, "roster_fence_inert").await;
        let db = Db::from_pool(pool.clone());

        sqlx::raw_sql(
            "CREATE OR REPLACE FUNCTION guard_channel_roster_snapshot() \
             RETURNS TRIGGER AS $$ BEGIN RETURN NEW; END; $$ LANGUAGE plpgsql;",
        )
        .execute(&pool)
        .await
        .expect("replace roster fence with inert body");
        let error = db
            .verify_channel_roster_fence()
            .await
            .expect_err("inert roster fence must fail closed");
        assert!(
            error
                .to_string()
                .contains("stale probe roster was accepted"),

View on GitHub (pinned to dad5a33865)

Solutions

  1. Start the required Postgres (just test prerequisites / docker compose) before running ignored tests
  2. Verify the admin connection string (host, port, user, password, sslmode) returned by admin_url()
  3. Test connectivity with psql using the same URL
  4. Check pg_hba.conf and max_connections if auth or limit errors appear

Example fix

// before
let admin = PgPool::connect(&admin_url().await).await.expect("connect admin");
// after
let admin = PgPool::connect(&admin_url().await).await
    .unwrap_or_else(|e| panic!("connect admin: {e} — is Postgres running?"));
Defensive patterns

Strategy: validation

Validate before calling

// probe the admin URL before PgPool::connect
let url = admin_url().await;
assert!(url.starts_with("postgres://"));
// or: tokio::net::TcpStream::connect((host, port)).await.expect("postgres reachable");

Try / catch

let admin = PgPool::connect(&url).await
    .map_err(|e| anyhow!("connect admin ({url}): {e}"))?;

Prevention

When it happens

Trigger: admin_url() points to a non-listening host/port, wrong credentials, TLS mismatch, or Postgres max_connections exhausted when running the test.

Common situations: Tests run without the required Postgres (`#[ignore = "requires Postgres"]` bypassed via --ignored), DATABASE_URL unset or wrong, Docker Postgres not started, pg_hba rejecting the user.

Related errors


AI-assisted analysis of block/buzz@dad5a33865 (2026-08-30). Data as JSON: /api/errors/86dcf18cc6262075. Report an issue: GitHub.