DBAtlas · Database operations atlas

Fix replication drops and an endless full resync loop (backlog, replica buffer)

RedisReplication

Command

INFO replication
# Master: connected_slaves, slaveN:...,state=online,offset=,lag=  Replica: master_link_status, master_last_io_seconds_ago, master_sync_in_progress
INFO stats
# sync_full / sync_partial_ok / sync_partial_err: repeated full syncs = backlog too small
CONFIG GET repl-backlog-size
CONFIG SET repl-backlog-size 256mb
# If the replica buffer exceeds its limit during a full sync, the link drops and sync starts over:
CONFIG GET client-output-buffer-limit
CONFIG SET client-output-buffer-limit "replica 1gb 512mb 120"

What it does

Shows link state, offset difference and partial/full sync counters on master and replica; grows the replication backlog so short disconnects do not turn into full syncs, and the replica output buffer limit so a full sync is not cut off midway.

When to use it

When a replica keeps looping on 'MASTER <-> REPLICA sync started', the sync_full counter grows, or the master log shows 'scheduled to be closed ASAP for overcoming of output buffer limits'.

Caution

Every full sync means a fork + RDB generation on the master; the loop strains master memory and disk. repl-backlog-size is allocated from master memory. Raising the replica buffer limit means the master may use that much extra memory during a full sync; include it in the maxmemory calculation. CONFIG REWRITE or redis.conf is needed to make changes persistent.

Open in DBAtlas →

Related