Database Replication: Primary and Replica Failover

Understand primary and replica topologies, synchronous and asynchronous replication, failover risks, replication lag, and why replicas do not replace backups.

published: reading time: 26 min read author: Geek Workbench updated: November 12, 2026
Quick Summary

A primary and its replicas can help with read capacity and recovery, but replication does not increase write capacity and is not a backup. Asynchronous replicas can lag, so promotion may lose acknowledged writes; synchronous commit settings reduce some loss windows but can block writes and do not replace fencing or recovery tests. This guide explains the failure sequence, the assumptions behind consistency claims, and the operational checks to run before promotion.

Database Replication: Primary and Replica Failover

Introduction

Database replication maintains copies of data on different servers. Replicas can serve some reads and may reduce recovery time after a primary failure, but neither result is automatic: stale reads, promotion policy, fencing, and traffic routing all matter. Replication copies changes, including accidental deletes or corruption, so it is not a backup or restore point.

This guide compares primary-replica and multi-primary designs, then looks at synchronous and asynchronous replication. It uses PostgreSQL and MySQL examples; check the documentation for the exact server version you run because terminology and settings change between releases.

A failover timeline

Consider an asynchronous PostgreSQL standby. At the moment the primary fails, the primary may have acknowledged writes through WAL position L2, while the standby has replayed only through L1.

  1. Detect and fence: the failover manager decides whether the primary is unavailable and prevents it from accepting writes if it can still be reached. Without fencing, a network partition can leave two writable primaries.
  2. Choose and promote: select a standby that is eligible under the recovery policy. If L1 is behind L2, writes after L1 may be lost from the new primary. This is the recovery point objective (RPO) exposed by asynchronous replication.
  3. Route traffic: update the writer endpoint and verify that only the promoted node accepts writes. Reads from other replicas remain stale until replay catches up.
  4. Rejoin safely: do not return the old primary to service as a writer. Rebuild or rewind it as a replica using the database’s supported recovery procedure.

Synchronous commit settings can reduce the acknowledged-write loss window, depending on which standby acknowledges and whether the commit waits for receipt, disk flush, or replay. They can also make commits wait or fail when the required standby is unavailable. They do not replace fencing, a promotion policy, or a tested recovery procedure. PostgreSQL describes these trade-offs in its high-availability documentation.

When to Use / When Not to Use

Use replication when you need:

  • Read scaling: Distribute SELECT queries across replicas to reduce primary load. Effective for read-heavy workloads where stale reads are acceptable.
  • High availability: A tested failover process can reduce recovery time. Detection, fencing, promotion, and routing still determine whether service resumes safely.
  • Geographic distribution: Place replicas in different regions to reduce read latency for distributed users.
  • Reporting and analytics: Offload read-intensive analytical queries to dedicated replicas, keeping the primary focused on OLTP workloads.
  • Maintenance with a planned failover: A replica can be promoted during maintenance, but the switchover may interrupt service and requires a tested plan.

Avoid replication when:

  • Write throughput is the bottleneck: Replication does not scale writes—only the primary accepts writes. If writes are your constraint, consider sharding or upgrading primary hardware.
  • Strong consistency is required for every read: Async replicas lag. If your application cannot tolerate stale reads after writes, you need either synchronous replication or read-from-primary-after-write patterns.
  • Your dataset exceeds a single server: Replication copies data, it does not partition it. For datasets too large for one server, you need sharding.
  • You need full-text search or complex joins at scale: Replicas are copies of the same relational schema. For search-heavy workloads, a separate index like Elasticsearch is more appropriate.
  • Your application is write-heavy with conflict-prone workloads: Multi-primary designs create write conflicts that require conflict resolution logic. The added complexity is justified only when write-availability requirements call for it.

Bottom line: Replication solves read scale and HA. It does not solve write scale. If your bottleneck is writes, go back to the drawing board and evaluate sharding.

Production Failure Scenarios

Failure Impact Mitigation
Primary failure without automatic failover Writes fail, extended downtime Implement automated failover, test failover regularly, have runbooks
Replication break due to divergent data Replica stops replicating, falls behind Use pt-table-checksum to detect drift, implement resync procedure
Network partition causing split-brain Two primaries accept writes independently Use quorum-based failover, implement fencing, test network partition scenarios
Replication lag buildup Read replicas return stale data Monitor lag, provision stronger replicas, switch to synchronous replication
Long-running query holding replication slots Replication cannot advance, WAL accumulates Kill long-running queries, tune max_slot_wal_keep_size
Cascading replication chain failure Leaf replicas fall far behind Keep replication chain short, monitor all replicas
Accidental replica promotion Application writes go to wrong server Protect against manual promotion, require multiple approvals
WAL corruption on primary Replicas replicate corrupted data Enable checksums, verify replica integrity regularly

Trade-off Analysis

Dimension Asynchronous Replication Synchronous Replication
Latency Low — primary does not wait High — primary waits for ack
Durability A promoted replica can miss acknowledged writes Can reduce the loss window under configured acknowledgment and promotion rules; may block writes
Availability Higher — writes never blocked Lower — writes blocked if replica down
Replica load Lower Higher
Cross-region support Practical at distance Impractical at distance (latency)
Use case Read scaling, non-critical data Financial, compliance-critical data
Dimension Primary-Replica Multi-Primary (Active-Active)
Write scalability None — single primary Scales writes across nodes
Conflict resolution None — single writer Required — same row can be written
Complexity Low High
Failure handling Simple failover Split-brain risk
Use case Most workloads Geo-distributed write availability

Common Pitfalls / Anti-Patterns

  1. Assuming replicas are consistent immediately after writes: With async replication, replicas lag. Do not read from replicas for critical data immediately after writes.

  2. Not monitoring replication lag: Lag accumulates silently until users complain. Monitor proactively and alert on threshold breaches.

  3. Promoting replica without verifying data: An incompletely replicated replica promoted to primary causes data loss. Verify replication is current before promotion.

  4. Using replicas for writes without understanding conflicts: Writes to replicas are typically replicated back. This can cause conflicts if not carefully designed.

  5. Ignoring replication slot retention: Slots prevent WAL removal. If replicas fall behind, WAL accumulates and can fill disk.

  6. Configuring weak authentication for replicas: Replicas with weak auth become attack vectors. Treat replica authentication as seriously as primary.

  7. Not testing failover procedures: If you have never tested failover, you will discover problems during actual outages. Test regularly.

  8. Mixing synchronous and asynchronous replication: This causes confusing behavior. Choose one replication mode per replica.

Quick Recap Checklist

  • Replication solves read scale and HA — not write scale
  • Async replication: low latency, risk of data loss on failover
  • Synchronous replication: a smaller loss window under the configured acknowledgment policy, with higher latency or reduced write availability
  • Semi-synchronous: at least one replica acknowledged before commit
  • Monitor replication lag on every replica; alert on anomalies
  • Verify replication is current before promoting a replica
  • Test failover procedures before production failures occur
  • Replication slots prevent WAL recycling — monitor disk usage
  • Strong auth and TLS encryption for replication connections
  • Multi-primary requires conflict resolution — use it only when its write-availability trade-off is needed

Interview Questions

1. What happens to replication lag when you add a read replica that is significantly weaker than other replicas?

The weaker replica cannot replay WAL entries as fast as the stronger replicas. Replication uses a single SQL thread for applying changes — if that thread cannot keep up with the primary's write rate, the weak replica falls behind. Meanwhile, stronger replicas stay current. The practical impact: if your application routes reads round-robin across replicas without checking lag, some users get stale data while others see current data. The fix is to either upgrade the weak replica's resources or exclude it from read distribution and use it only for specific low-throughput tasks.

2. Your application writes to a primary and immediately reads from a read replica. Under asynchronous replication, what consistency guarantee does the read see?

There is no read-after-write guarantee unless the database and routing policy provide one. An asynchronous replica may not have received the write yet. Route the session to the primary, or wait until a replica has replayed a known commit position. Synchronous settings can change what the primary waits for, but the acknowledgment level and promotion policy determine what that protects.

3. What is the difference between synchronous and semi-synchronous replication?

Synchronous replication waits for all configured replicas to acknowledge writes before committing the transaction on the primary. If any replica does not acknowledge within a timeout, the write fails. Semi-synchronous replication waits for at least one replica to acknowledge, then commits on the primary. If no replica acknowledges within the timeout, it falls back to asynchronous replication and commits anyway. PostgreSQL calls this synchronous_commit = on for synchronous and synchronous_commit = remote_apply or remote_write for the various semi-synchronous modes.

4. A financial application has a strict recovery point objective. How would you choose and validate its replication policy?

Start from the required RPO, then choose a database-specific synchronous acknowledgment policy and a failover process that promotes only an eligible replica. Confirm whether acknowledgment means receipt, durable flush, or replay, and what happens if the required standby is unavailable. Rehearse a primary failure and verify the actual data loss window. Synchronous replication can narrow that window, but the result depends on configuration and failure mode; it does not make the whole system loss-proof.

5. What does R + W > N tell you about read and write quorums, and what does it leave unspecified?

For a system with N replicas, R + W > N makes any R-member read set overlap any W-member write set. That overlap alone does not prove linearizability or even that a read chooses the newest value. Version ordering, conflict resolution, quorum rules, and the system's consistency protocol matter. When R + W ≤ N, the sets can be disjoint, so a read may miss a write. Treat the formula as a condition in a stated quorum model, not a universal consistency guarantee.

6. What is cascading replication and when does it make sense to use it?

Cascading replication chains replicas so that a replica follows another replica instead of the primary directly. Data flows: Primary → Replica1 → Replica2 → Replica3. This reduces load on the primary when you have many replicas, because the primary only needs to send WAL entries to one first-tier replica instead of N replicas. The tradeoff is increased replication lag — data takes longer to reach leaf replicas since it must flow through intermediate nodes. Cascading makes sense for read-heavy workloads where staleness is acceptable and you need many replicas. It does not make sense when lag must be minimized or when you need synchronous replication to all replicas.

7. How does replica promotion work in automatic failover, and what are the main risks?

Automatic failover works by having a monitor process detect primary failure through health checks, reaching consensus among monitors that the primary is down, selecting the most current replica based on WAL position, promoting that replica to primary, and redirecting traffic through a proxy. The main risks include: (1) Split-brain where two servers think they are primary due to network partition — mitigated by quorum-based consensus; (2) Data loss if the promoted replica has not received the latest writes from the async primary — mitigated by semi-synchronous replication; (3) Write burst overwhelming the new primary before it stabilizes; (4) A weak replica being promoted when a stronger one was available. Testing failover regularly and having operator verification for critical systems helps manage these risks.

8. What is the difference between read-after-write consistency and eventual consistency in replicated databases?

Read-after-write consistency (also called read-your-writes) guarantees that after a client writes data, subsequent reads by the same client see that write. In an async replicated system, this requires reading from the primary after writes, because replicas may not have received the write yet. Eventual consistency only guarantees that if no new writes are made, all replicas will eventually converge to the same value — but a read immediately after a write may return stale data. Read-after-write is a stronger guarantee. Techniques to achieve it include: routing writes to primary then subsequent reads to primary for a session window; using synchronous replication so replicas are current; or tracking the minimum LSN that a client has seen and routing reads to replicas that have replayed past that LSN.

9. Why can replication slots be dangerous if not managed properly?

Replication slots prevent WAL (Write-Ahead Log) from being removed on the primary as long as a replica has not acknowledged receiving those WAL entries. This is designed to prevent data loss — if a replica falls behind and then reconnects, it can resume from where it left off without the WAL having been recycled. The danger: if a replica falls behind significantly (due to being offline, a slow network, or a long-running query holding the slot) or if a slot is created but the replica never actually connects, WAL accumulates on the primary's disk. If left unchecked, this can fill the entire disk, causing the primary to stop accepting writes entirely. PostgreSQL's max_slot_wal_keep_size parameter limits how much WAL a slot can retain, and wal_keep_size provides a simpler floor for all replicas.

10. How does Amazon Aurora's shared storage replication differ from traditional primary-replica replication?

Traditional replication replicates SQL statements or WAL entries from primary to replicas. Aurora separates compute and storage — the primary and replicas all share the same 6-node storage volume across 3 AZs. When the primary writes a page, it is acknowledged after 4 of 6 storage nodes commit. Replicas read from the same shared storage, so there is no traditional replication lag — a replica sees the same data as the primary as soon as it is written. This gives single-digit millisecond replica lag under normal operation. The tradeoff is write throughput is limited by storage layer capacity, and cross-region replication is asynchronous with higher lag since the shared storage is region-local. Aurora's model works well for most applications but can bottleneck for write-heavy workloads.

11. What is the difference between a cascading replica and a direct replica?

A direct replica receives changes from the primary. A cascading replica receives them from another replica and forwards them downstream. Cascading can reduce the number of direct connections to the primary, but it adds another point where lag or failure can delay downstream replicas. Whether that topology helps depends on the network and workload; measure lag at each hop and avoid treating a healthy local apply process as proof that the leaf is current.

12. Describe how GTID (Global Transaction Identifier) replication works and what advantages it provides over file-position based replication.

GTIDs identify transactions independently of a binary log file and byte offset, which can simplify replica positioning after a topology change. MySQL option names vary by version; MASTER_AUTO_POSITION is an older literal option name, so use the syntax documented for the server release you run. GTIDs do not remove the need to check which transactions a candidate replica has executed before promotion.

13. What is semi-synchronous replication and when would you choose it over full synchronous or asynchronous replication?

Semi-synchronous replication is a middle ground: the primary waits for at least one replica to acknowledge receipt of a write before committing, but does not wait for all replicas. If no replica acknowledges within a timeout, the primary falls back to asynchronous mode and commits anyway. This gives stronger durability than async (at least one replica has the write) while avoiding the latency of waiting for all replicas. PostgreSQL implements this via synchronous_commit = remote_apply which waits for the replica to replay the transaction, or remote_write which only waits for the replica to write to disk. You would choose semi-synchronous when: you want at least one durable copy but cannot tolerate the latency of waiting for all replicas; you need protection against total primary failure without the full performance cost of synchronous replication; or you are in a hybrid environment where some replicas must be synchronous and others can be async.

14. Your application is experiencing periodic spikes in replication lag during peak hours. What are the most likely causes and how do you diagnose and fix them?

Common causes of periodic lag spikes include: (1) A long-running query on the replica holding back the SQL replay thread — diagnose with SHOW PROCESSLIST on the replica or pg_stat_activity in PostgreSQL; (2) A bulk data load or batch job on the primary generating WAL faster than replicas can consume — monitor WAL generation rate vs replay rate; (3) Network saturation between primary and replica — check network throughput metrics; (4) Replica resource exhaustion (CPU, disk IOPS) — monitor replica host metrics; (5) Replication slot holding back WAL when a replica falls behind — check pg_replication_slots; (6) Increasing table bloat on the primary causing larger WAL records. Fixes include: provisioning stronger replicas, adding parallel apply for the replica SQL thread (MySQL), tuning max_standby_streaming_delay in PostgreSQL, offloading analytics queries from replicas used for OLTP, and using cascading replication to reduce primary load.

15. What techniques can you use to route reads to replicas while minimizing stale reads?

Several approaches reduce stale reads without routing everything to the primary. (1) Latency-aware routing: route reads to the nearest replica to reduce lag and network delay. (2) Monotonic reads: ensure a client always reads from the same replica or one that has seen all previous writes from that client. (3) Read-after-write targeting primary: read from primary for a session window after writes, then fall back to replicas. (4) LSN-based routing: track the replication position after writes and route reads only to replicas that have replayed past that LSN. (5) Hinted handoffs: in Cassandra-style systems, a replica that receives a read request but is behind forwards the request to a more current replica, reads from it, and returns the fresher data. For PostgreSQL, you can use pg_stat_replication to check replay_lsn and only route reads to replicas whose lag is below your tolerance threshold.

16. How does leader-based replication differ from leaderless replication, and what are the trade-offs?

Leader-based replication has one write leader and replicas that apply its changes. Leaderless systems accept operations at multiple nodes and reconcile them using their own consistency and conflict rules. The quorum condition R + W > N may make read and write sets overlap in some models, but it does not by itself guarantee consistency. Compare the product's documented guarantees and failure behavior before choosing either design.

17. What is the difference between statement-based, row-based, and hybrid replication in MySQL?

MySQL supports three binary log formats. Statement-based replication (SBR) logs the SQL statements themselves — simpler, less data logged, but can produce nondeterministic results for functions like NOW() or UUID(). Beyond nondeterministic functions, SBR has two additional practical drawbacks: triggers can produce different outcomes on replicas if the trigger logic depends on state that differs between primary and replica, and SBR cannot work correctly with multi-statement transactions that have no snapshot isolation (e.g., a transaction doing two consecutive reads where the second read depends on the first read's result — on a replica, the non-deterministic ordering can cause different outcomes). Row-based replication (RBR) logs the actual row changes — guarantees consistency for nondeterministic statements but can produce very large binlogs for bulk updates. Hybrid replication (MIXED) uses statement-based by default but switches to row-based for statements known to be nondeterministic. In practice, row-based is now the default in MySQL 8.0 because it is safer. Statement-based can be faster for bulk operations on tables with many rows, but the inconsistency risks rarely make it worth the disk savings.

18. How does pglogical differ from built-in PostgreSQL streaming replication?

PostgreSQL streaming replication (physical replication) copies the entire database byte-for-byte via WAL records. It is block-level and database-wide — you cannot replicate a single table or database. pglogical is a logical replication extension that replicates at the row and DDL level. With pglogical, you can replicate specific tables, specific databases, or subsets of data using publication/subscription. Logical replication also lets you do zero-downtime major version upgrades by having the new version subscribe to the old version's changes. The tradeoff is that logical replication has higher overhead per transaction (more CPU) because it must decode WAL into individual row changes, whereas streaming replication just streams raw WAL bytes. Logical replication also requires the schema to be mostly compatible between publisher and subscriber.

19. What is the dual-primary configuration and why is it generally discouraged?

Dual-primary (also called active-active) means two database servers are both configured as primaries, each accepting writes and replicating to the other. Both are simultaneously writable. The appeal is write load distribution and geographic proximity to users. The problem is conflict resolution — if the same row is updated on both primaries within the replication window, you get a write conflict. Depending on your conflict resolution strategy (last-write-wins, manual resolution, application-level handling), you risk data divergence, lost updates, or application errors. The window of conflict is every millisecond two servers are accepting writes independently. Most databases with dual-primary configurations end up requiring application-level logic to serialize writes (e.g., shard by key range so each primary owns different rows), which defeats the purpose. For most use cases, a single primary with read replicas and a proper failover mechanism handles the job better.

20. Describe how change data capture (CDC) relates to database replication and when you would use it over traditional replication.

CDC is a pattern where you capture changes (inserts, updates, deletes) from a database's transaction log and publish them as an event stream. Tools like Debezium, AWS DMS, or Postgres' logical replication slots do this. CDC differs from traditional replication in that the output is an event stream rather than a direct replica — downstream consumers can be data warehouses, search indexes, other databases, or microservices. You would use CDC over traditional replication when: you need to feed multiple downstream systems (not just one replica set), you want loose coupling between source and sink (events can be replayed, filtered, transformed), you are doing a migration and need to keep systems in sync during the transition, or you need to build audit logs or time-travel queries. The tradeoff is operational complexity — CDC pipelines require monitoring, schema evolution handling, and event ordering guarantees.

  • Database Scaling covers read replicas, bottlenecks, and capacity decisions.
  • Disaster Recovery explains backups, restore tests, and recovery exercises.
  • Data Migration covers moving records between systems; replication alone is not a migration plan.

Further Reading

Official Documentation:

Books and Papers:

  • Designing Data-Intensive Applications by Martin Kleppmann — Chapters on replication (Ch. 5) and distributed data (Ch. 6, 8) provide foundational theory
  • Database Internals by Alex Petrov — Deep dive into storage engines, WAL mechanisms, and replication internals

Tools and Utilities:

  • pgpool-II: Connection pooling and replication proxy for PostgreSQL
  • PgBouncer: Lightweight connection pooler for PostgreSQL
  • Vitess: MySQL sharding proxy that also handles replication routing
  • patroni: PostgreSQL HA template using consensus-based failover
  • orchestrator: MySQL replication topology management and failover tool
  • percona-toolkit: Includes pt-table-checksum for detecting replication drift

Monitoring Queries:

-- PostgreSQL: replication lag monitoring
SELECT
    client_addr,
    state,
    sent_lsn - replay_lsn AS replication_lag_bytes
FROM pg_stat_replication;

-- MySQL: replica lag monitoring
SHOW REPLICA STATUS\G
-- Key fields: Seconds_Behind_Source, Relay_Log_Pos, Exec_Source_Log_Pos

Conclusion

  • Replication provides high availability and read scale; it does not scale writes
  • Asynchronous replication is faster but allows stale reads and potential data loss
  • Synchronous replication can reduce acknowledged-write loss under a specific commit policy, at the cost of latency or write availability
  • Monitor replication lag on every replica and alert on anomalies
  • Test failover procedures before you need them in production
  • Multi-primary creates conflict-resolution complexity; use it only when the write-availability requirements justify it

Copy/Paste Checklist:

-- PostgreSQL: Set up synchronous replication
ALTER SYSTEM SET synchronous_commit = on;
ALTER SYSTEM SET synchronous_standby_names = 'replica1,replica2';

-- MySQL: Configure replica with GTID
CHANGE REPLICATION SOURCE TO
    SOURCE_HOST = 'primary-host',
    SOURCE_USER = 'repl_user',
    SOURCE_PASSWORD='***',
    SOURCE_AUTO_POSITION = 1;

START REPLICA;

-- Monitor replication health
SELECT * FROM pg_stat_replication;
SHOW REPLICA STATUS;

Observability Checklist

Metrics to Monitor:

  • Replication lag in seconds (primary vs each replica)
  • Replica IO and SQL thread status
  • Replica heartbeat/lag metrics
  • WAL generation rate vs replay rate
  • Replication slot age (if using slots)
  • Disk usage on replicas vs primary
  • Connection count per replica
  • Error count on replication threads

Logs to Capture:

  • Replication state changes (connect, disconnect, error)
  • Replication conflict events (duplicate key, deadlocks)
  • Long-running queries on replicas blocking replication
  • Checkpoint and WAL activity
  • Failover events and decisions

Alerts to Set:

  • Replication lag > 30 seconds (adjust to your SLA)
  • Replica IO/SQL thread stopped
  • Replication slot age > threshold
  • Disk usage on replica > 80%
  • High number of replication conflicts
  • Replica connection failures
-- PostgreSQL: Monitor replication status
SELECT client_addr, state, sent_lsn, write_lsn,
       flush_lsn, replay_lsn,
       sent_lsn - replay_lsn AS replication_lag
FROM pg_stat_replication;

-- MySQL: Check replica status
SHOW REPLICA STATUS\G

Security Checklist

  • Use strong authentication for replication connections (scram-sha-256, certificates)

    The replication channel puts your database write path on display. If replica credentials leak, an attacker can read data and potentially push writes through the replication stream. Password-based auth resists replay attacks but still sends credentials over the wire. Certificate authentication drops passwords from the replication channel entirely — the right call for production.

  • Encrypt replication traffic with TLS

    Without TLS, replication traffic crosses your network in plaintext. Anyone on that network segment sees your entire database: row data, session variables, sometimes auth tokens. Even in trusted datacenter networks, a compromised server exposes unencrypted replication streams. Enforce encryption at both ends.

  • Restrict replication user to replica connections only

    The replication user needs only the minimum privilege for its function. PostgreSQL’s REPLICATION privilege and MySQL’s REPLICATION CLIENT and REPLICATION SLAVE privileges are sufficient, nothing else. Lock connections to known replica addresses through pg_hba.conf or MySQL host grants. This keeps the blast contained to infrastructure that legitimately needs access.

  • Implement network segmentation for replication traffic

    Replication traffic belongs on an isolated network segment, not the general application network. If your application network gets breached, an isolated replication segment stops the attacker from reaching the replication channel directly. In cloud environments, put primaries and replicas in a private subnet with no direct internet access, and use VPC peering or private links for cross-AZ replication.

  • Use separate credentials for replication (not application credentials)

    Never share application credentials with the replication channel. If your application credentials are compromised through SQL injection or a leaked config file, shared credentials hand the attacker immediate replication access. Dedicated replication credentials per environment mean you can rotate them without touching application configuration, and you can revoke replication access without affecting the application itself.

  • Audit replication configuration changes

    Replication configuration changes — auth settings, TLS parameters, replication user permissions, pg_hba.conf rules, or MySQL CHANGE REPLICATION SOURCE options — need review. A single misstep, like switching from certificate auth to trust method, silently opens your database. Enable audit logging for configuration changes and alert on unexpected modifications.

  • Review replication credentials under the organization’s threat-driven access policy

    Use separate, least-privilege replication credentials. Set rotation and revocation rules from credential exposure risk, access scope, and incident response requirements; a fixed quarterly or monthly schedule is not appropriate for every environment. Verify credential changes against the database version and replication tooling before applying them.

  • Monitor authentication failures on replication ports

    Authentication failures on the replication port are a warning sign. A replica that drops and reconnects should authenticate cleanly. Repeated failures mean either a misconfigured replica or someone probing the replication endpoint with guessed credentials. Set up alerting on replication port authentication failures to catch credential attacks early.

  • Verify replica SSL certificates

    TLS without certificate verification does not actually protect you. A man-in-the-middle attacker could terminate the TLS connection, decrypting and re-encrypting traffic between primary and replica. Both PostgreSQL and MySQL replicas must verify the primary’s certificate — otherwise an attacker can impersonate the primary and sit in the middle of the connection.

Category

Related Posts

Asynchronous Replication: Lag, Failover, and Freshness

Learn how asynchronous database replication affects read freshness, failover data loss, lag monitoring, and recovery choices during network partitions.

#distributed-systems #replication #eventual-consistency

Synchronous Replication: Data Consistency Across Nodes

Learn about synchronous replication patterns in distributed databases, including Quorum-based replication and write-ahead log shipping for zero RPO.

#distributed-systems #replication #consistency

CRDTs: Conflict-Free Replicated Data Types

Learn how conflict-free replicated data types converge after concurrent updates, and where counters, LWW registers, and observed-remove sets fit.

#distributed-systems #crdt #eventual-consistency