After a Multi-AZ failover, some app servers keep failing with connection errors for 10+ minutes while others recover in a minute.
AdvancedTroubleshootingRDS, Aurora and DynamoDB
Answer
Likely causes → A failover flips the endpoint's DNS CNAME to the standby. Clients that cache DNS for a long time (JVM networkaddress.cache.ttl set to forever, or a misconfigured local resolver) or keep stale pooled connections keep hitting the old IP.
Diagnose →
aws rds describe-events --source-identifier mydb --source-type db-instance --duration 120
dig +short mydb.abc.us-east-1.rds.amazonaws.com
# on the bad host
getent hosts mydb.abc.us-east-1.rds.amazonaws.com
Fix →
- Set the JVM DNS TTL to a low value (
networkaddress.cache.ttl=5) - Turn on pool connection validation and max lifetime (for example, HikariCP
maxLifetime) - Restart the affected app instances to recover now
Prevent → Use RDS Proxy (it keeps client connections during failover) or the AWS Advanced JDBC Wrapper, and test failover regularly with aws rds reboot-db-instance --force-failover.
More on RDS, Aurora and DynamoDB
The app cannot connect to RDS: `psql: error: connection to server at "mydb.abc.us-east-1.rds.amazonaws.com" (10.0.3.12), port 5432 failed: Connection timed out`.Beginner`FATAL: password authentication failed for user "postgres"` and nobody knows the master password.Beginner`FATAL: no pg_hba.conf entry for host "10.0.1.25", user "app", database "orders", no encryption`.IntermediateApp logs show `FATAL: remaining connection slots are reserved for non-replication superuser connections` (or MySQL `ERROR 1040 (HY000): Too many connections`).IntermediateRDS status shows `storage-full` and writes fail.IntermediateA read replica's `ReplicaLag` keeps growing and reports show stale data.Intermediate