Pcornel
Browse topics
Options
Recent
Favorites
Databases · Technical reference

Replication & High Availability

Direct answer

Replication copies data to other servers for read scaling and availability; high availability adds automatic failover (Patroni, Always On AGs, Galera, orchestrators).

When to use this

Use it to design or troubleshoot replicas and failover.

First 30 seconds

1. Replication state: pg_stat_replication / SHOW REPLICA STATUS\G / AG dashboard.

2. Lag within target?

3. Failover tested?

4. Clients reconnect to the new primary (VIP/DNS/proxy)?

5. Quorum/witness configured.

Operational verification

primary writes WAL/binlog → shipped to replicas → applied → failover promotes a replica

Evidence · next step

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. Preserve the first divergent observation and repeat the same bounded verification after remediation.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
What not to infer

Databases owns engine replication/failover semantics. Networking owns transport/name resolution; Storage owns shared/replicated media where applicable; backup remains a separate protection layer.

Platform / version applicability
MariaDB / MySQL / PostgreSQL / Microsoft SQL Server concepts
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformMariaDB / MySQL / PostgreSQL / Microsoft SQL Server concepts · Databases owns engine replication/failover semantics. Networking owns transport/name resolution; Storage owns shared/replicated media where applicable; backup remains a separate protection layer.
Scope / prerequisiteUse it to design or troubleshoot replicas and failover.
What next?3 suggested next steps
Child topics (this level)3
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification workflow Verify boundary

Verify source/primary identity, replica receive/apply position, lag and health from both sides. Exercise a documented failover in a bounded environment, confirm client reconnection and writable/read-only role, then validate failback/resynchronization and backup continuity.

Step 2 Failure signatures and limits Narrow the fault

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.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

test · 1
Drill down

Subtopics

Go one level deeper into this subject.

Key points

Asynchronous replicas can lose recent transactions on failover; synchronous ones add latency. Monitor lag. Prevent split brain with a quorum/witness.

Key checks
  • pg_stat_replication — first check for this topic
  • psql -c "SELECT now(), version();" — PostgreSQL reachable and version
  • mysql -e "SELECT NOW(), VERSION();" — MariaDB/MySQL reachable and version
  • sqlcmd -S <server> -Q "SELECT @@VERSION" — SQL Server reachable and version
ReferenceWhat it is1 section · depth on demand

Operating model

Replication & High Availability covers keeping database copies synchronized enough to serve read scaling or failover. Synchronous modes trade latency/availability for stronger acknowledgement semantics; asynchronous modes can lose recent committed data at failover. HA reduces service interruption but does not protect against every logical/data-corruption event.

ReferenceHow it works1 section · depth on demand

In depth

Replication copies data from a primary to one or more replicas, providing read scaling, faster failover and disaster recovery. High availability adds automatic or managed failover so applications keep working when the primary fails.

EngineReplicationHA tooling
PostgreSQLStreaming (physical), logicalPatroni, repmgr, cloud managed services
MariaDB/MySQLBinlog (GTID), semi-sync; Galera (MariaDB)Orchestrator, MaxScale, InnoDB Cluster
SQL ServerAlways On availability groups, log shippingWindows/Pacemaker clusters, listeners

Key concepts:

ConceptMeaning
SynchronousCommit waits for replica — no data loss, higher latency
AsynchronousFaster; recent transactions can be lost on failover
Replication lagHow far replicas are behind
Split brainTwo primaries — prevented with quorum/fencing

Replication is not a backup: deletions and corruption replicate too. Monitor lag and test failover regularly.

ReferenceImportant terms & boundaries1 section · depth on demand

Scope map

  • Primary/replica model
  • Synchronous vs asynchronous replication
  • Replication lag
  • Read replicas
  • Failover/failback
  • Split-brain/fencing concepts
  • HA does not replace backup
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical examples

Configuration & expected output

Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.

Configuration example

PostgreSQL PostgreSQL 14 or laterCheck streaming replication state and lag from the primary.

Assumptions: One primary and at least one physical standby.

SELECT client_addr, state, sync_state,
       pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn) AS replay_lag_bytes,
       replay_lag
  FROM pg_stat_replication;

Expected output

PostgreSQL PostgreSQL 14 or laterSELECT client_addr, state, sync_state, replay_lag FROM pg_stat_replication;

Expected state: Each standby is streaming and replay lag stays small and stable.

client_addr |   state   | sync_state |   replay_lag
-------------+-----------+------------+-----------------
 10.0.10.23  | streaming | async      | 00:00:00.012
(1 row)
A missing row means the standby is not connected at all. async standbys can lose recent commits on failover; sync standbys trade latency for that guarantee. Illustrative authored output: field layout matches the tool, values will differ in your environment.
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-29 · otherMariaDB / PostgreSQL / Microsoft SQL Server concepts PostgreSQL current documentation

Documentation verification: confirms the upstream model used by the Topic. It does not assert local production behavior.

Basis: https://www.postgresql.org/docs/current/high-availability.html · confidence 92%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
replication & high availabilitydatabase replicationdatabase high availabilityreplication lagdatabase failover
Embedded reference data

Quick lookup tables

Replication & High Availability verification boundary matrix

A compact lookup separating intent, owning component state, effective state and consumer-visible outcome for Replication & High Availability.

BoundaryInspectHealthy interpretationDo not infer
IntentPrimary/replica modelIntended object/scope is explicit and versioned where relevantIntent is already effective
Owning runtime/control planeSynchronous vs asynchronous replication / Replication lagOwner accepts and reports the expected object stateDownstream dependencies are healthy
Effective stateRead replicasIndependent read-back matches the intended stateEvery client sees the same result
Consumer outcomeFailover/failbackThe original bounded check succeeds in the same time windowProduction correctness outside this scope
Depth when you need it

Deep reference

Design & tradeoffs

Scope

Databases owns engine replication/failover semantics. Networking owns transport/name resolution; Storage owns shared/replicated media where applicable; backup remains a separate protection layer.

Confirmation

Confirm action

Continue?