Ecto connection pool retains stale IP after DNS change
0 reputation · 14 May 2020, 21:52 UTC
Symptom
When the IP address associated with a hostname used by an Ecto.Repo changes after the connection pool has been started, existing connections continue to resolve to the former address until the pool is recycled.
The underlying behavior stems from Erlang’s :inet resolver being called only when a socket is first opened, and SSL/TLS certificate validation is performed via the :ssl option in the repo config.
Goal: Determine whether Ecto can be configured to refresh DNS resolution (including SRV records) on each connection checkout or to honor a configurable TTL without requiring a pool restart.
Constraints: The effect varies by adapter (some bypass :inet), Erlang/OTP version, and the way connection strings are constructed.
- Does Ecto expose an option to force hostname re‑resolution on every checkout?
- Can a TTL‑based DNS refresh be introduced through pool settings without restarting the supervision tree?
- Are there adapter‑specific pathways that ignore Erlang’s :inet and therefore bypass any Ecto‑level DNS handling?