neondatabase/neon · error

failed to get list of active logical replication subscriptio

Error message

failed to get list of active logical replication subscriptions: {}

What it means

check() runs `select count(*) from pg_stat_subscription where pid is not null` so a compute with an active logical replication subscription is not suspended (the pid filter excludes read-only computes and subscriptions on branches). This error means query_one itself failed - broken connection, timeout, server error, or pg_stat_subscription not existing. It marks downtime and triggers the monitor reconnect path.

Source

Thrown at compute_tools/src/monitor.rs:316

        const LOGICAL_SUBSCRIPTIONS_QUERY: &str =
            "select count(*) from pg_stat_subscription where pid is not null;";
        match cli.query_one(LOGICAL_SUBSCRIPTIONS_QUERY, &[]) {
            Ok(row) => match row.try_get::<&str, i64>("count") {
                Ok(num_subscribers) => {
                    if num_subscribers > 0 {
                        self.last_active = Some(Utc::now());
                        return Ok(());
                    }
                }
                Err(e) => {
                    return Err(anyhow::anyhow!(
                        "failed to parse 'pg_stat_subscription' count: {}",
                        e
                    ));
                }
            },
            Err(e) => {
                return Err(anyhow::anyhow!(
                    "failed to get list of active logical replication subscriptions: {}",
                    e
                ));
            }
        }

        // Do not suspend compute if autovacuum is running
        const AUTOVACUUM_COUNT_QUERY: &str =
            "select count(*) from pg_stat_activity where backend_type = 'autovacuum worker'";
        match cli.query_one(AUTOVACUUM_COUNT_QUERY, &[]) {
            Ok(r) => match r.try_get::<&str, i64>("count") {
                Ok(num_workers) => {
                    if num_workers > 0 {
                        self.last_active = Some(Utc::now());
                        return Ok(());
                    };
                }
                Err(e) => {

View on GitHub (pinned to 8f60b04da4)

Solutions

  1. Check the appended error string for the SQLSTATE - 'relation does not exist' (42P01) points to a missing view, connection errors point to transport
  2. Confirm the compute runs Postgres 10 or newer when logical subscriptions are used
  3. Let the monitor self-heal via reconnect for transient failures
  4. Reproduce manually as cloud_admin: select count(*) from pg_stat_subscription where pid is not null;
Defensive patterns

Strategy: retry

Try / catch

match cli.query_one(LOGICAL_SUBSCRIPTIONS_QUERY, &[]) {
    Ok(row) => { /* parse count, keep alive if > 0 */ }
    Err(e) => { error!("subscriptions check failed: {e}"); client = conf.connect(NoTls); }
}

Prevention

When it happens

Trigger: cli.query_one on pg_stat_subscription returns Err: connection dropped mid-poll, statement timeout, Postgres restarting, or running on a server where the pg_stat_subscription view is absent (it exists only on PG 10+).

Common situations: Monitor polling during Postgres restarts or suspend transitions; environments running Postgres forks or versions lacking the subscription stats view; transient 'relation does not exist' during catalog upgrades.

Related errors


AI-assisted analysis of neondatabase/neon@8f60b04da4 (2026-08-16). Data as JSON: /api/errors/93f8025789ac7946. Report an issue: GitHub.