Re:We migrated our PostgreSQL database with 11 seconds downtime
by juggertao on Friday January 19, 2024 @01:11AM
(#39052082)
They mentioned they had a script which terminated all connections to the old database then changed the password.
But on the app side you typically don't cache DNS, that creates other problems like stale DNS.
getaddrinfo(3) and getnameinfo(3) (guessing that's what you meant) don't implement caching, at least not explicitly in the spec and not normally in practice. On Windows, DNS results are cached by the OS but on Linux that would be distro-dependent behavior and usually requires setting up a local caching dns server (Ubuntu uses unbound out-of-the-box, iirc. Other choices include ncsd and dnsmasq).
Even if they implemented caching at the syscall level, this still assumes no connection stays open for more than 1s or is reused except per query. It seems like a big assumption (at least I hope it is, because I certainly wouldn't want my app to initialize a new db connection, let alone perform a DNS lookup, for every query).