Skip to content

table-diff can exhaust a node's connection pool (no headroom) — HA failover risk #203

Open

Description

@zaidshabbir25

Component / Links: ACE · PR #193 (strict connection limit per instance)

Type: Bug (robustness/safety) · Priority: High on HA clusters

Description:
With a large --max-connections/-M (or max_connections config), ACE opens connections until the server refuses (SQLSTATE 53300) with no reserved headroom, and holds them for the whole run (KeepOpen). A single table-diff can consume 100% of a node's available connections and lock out all other clients, including Patroni health checks.

Environment (generic): 2-node cluster, max_connections=100, superuser_reserved_connections=3. ACE connects as a superuser.

Steps to reproduce:

  1. ace table-diff demo -M 100 -n n1,n2
  2. Observe other clients on each node.
  3. Actual: ACE opens 97/96 connections per node (the entire non-reserved pool + reserved, since it runs as superuser). All other connection attempts fail with FATAL: sorry, too many clients already for the duration. Diff completes correctly.

    Expected: ACE reserves headroom and never drains the pool; other clients (and HA tooling) keep working. A limit that exceeds the node's capacity should warn/refuse rather than silently monopolize.

    Impact: On Patroni/HA clusters, starving liveness connections can trigger a false "node down" → failover. A modest misconfiguration (e.g. -M ~90 on max_connections=100) is enough.

    Code refs: internal/infra/db/auth.go (OpenConns acquires until 53300; KeepOpen/keepOpenLifetime), pkg/config/config.go (MaxConnectionsPerNode = 262143 — no real ceiling).

    Suggested fix: (1) reserve headroom below max_connections − reserved; (2) a sane configurable ceiling or a loud warning when N approaches the node's max_connections; (3) document the hazard by the setting.

Activity

  1. danolivo commented on Nov 9, 2026

    @danolivo
    Contributor

    @zaidshabbir25 , what exactly is the problem here? Consider: you set max connections to 1. You need at least one, right? But it also might be the last one on the server and cause 'connection exhaustion'.
    What we did here was let the DBA tell ACE how many connections it can use safely. Not sure if there are any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions