You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
table-diff can exhaust a node's connection pool (no headroom) — HA failover risk #203
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:
ace table-diff demo -M 100 -n n1,n2
Observe other clients on each node.
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.
@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.
Activity
danolivo commentedon Nov 9, 2026
@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.