Replication & High Availability
Cheat sheet · https://pcornel.dk/topic.php?topic=6094
Answer
Replication copies data to other servers for read scaling and availability; high availability adds automatic failover (Patroni, Always On AGs, Galera, orchestrators).
Remember
Asynchronous replicas can lose recent transactions on failover; synchronous ones add latency. Monitor lag. Prevent split brain with a quorum/witness.
First checks
pg_stat_replication— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
Verify in this order
primary writes WAL/binlog → shipped to replicas → applied → failover promotes a replica
Where it usually breaks
Failures include connected-but-stalled replicas, hidden lag, wrong read/write routing, split brain, stale DNS/listener targets, missing fencing, replication of accidental deletes and promoting a replica without understanding data-loss position.
Replication & High Availability verification boundary matrix
| Boundary | Inspect | Healthy interpretation | Do not infer |
|---|---|---|---|
| Intent | Primary/replica model | Intended object/scope is explicit and versioned where relevant | Intent is already effective |
| Owning runtime/control plane | Synchronous vs asynchronous replication / Replication lag | Owner accepts and reports the expected object state | Downstream dependencies are healthy |
| Effective state | Read replicas | Independent read-back matches the intended state | Every client sees the same result |
| Consumer outcome | Failover/failback | The original bounded check succeeds in the same time window | Production correctness outside this scope |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6094