BlogValkey

Valkey Replica Full Resync Loops: Sizing the Backlog

Scott Sternloff

By Scott Sternloff, Senior Enterprise Architect

LinkedIn · Updated · 4 min read

Valkey Replica Full Resync Loops: Sizing the Backlog
On this page

Short answer

A Valkey replica falls back to a full resync when the primary's replication backlog no longer holds the data it missed. It loops when the sync itself cannot finish, usually because the replica output buffer limit is hit while the snapshot is sent. Size repl-backlog-size to write rate times the longest outage you want to survive, then check client-output-buffer-limit replica and latest_fork_usec.

A Valkey replica does a full resync when the primary's replication backlog no longer holds the data the replica missed. It loops when the full sync cannot finish, usually because the replica's output buffer on the primary hits its limit while the snapshot is being sent. Size repl-backlog-size to write rate times your longest tolerated outage, then check the buffer limit and fork time. Settings below are from the Valkey replication topic and the valkey.conf reference, read 3 December 2026.

If a cluster is already in this loop and writes are suffering, our valkey consulting engineers start from the same INFO fields.

When does a replica need a full resync instead of a partial one?

After a disconnect, the replica sends its replication ID and offset with PSYNC. The primary can answer with only the missing bytes if they are still in its backlog. The primary falls back to a full resync when its buffers no longer hold the missing bytes, or when it does not recognise the replica's replication ID. After a failover the promoted replica keeps the old primary's ID as a secondary ID, so other replicas can usually still resync partially.

The default repl-backlog-size is 10mb. On a primary taking even modest writes, 10mb covers a short blip, not a failed deploy or a network flap. The backlog is allocated only when at least one replica is connected, and repl-backlog-ttl (default 3600 seconds) controls when it is freed after the last replica leaves.

How do you size repl-backlog-size?

  1. Measure the write rate. Read master_repl_offset from INFO replication twice during peak load, a minute apart, and divide the difference by the elapsed seconds.
  2. Choose the outage window. The longest disconnect you want to recover from without a full copy, such as a 10-minute maintenance restart.
  3. Multiply and add headroom. Example: 5 MB a second for 600 seconds is 3,000 MB, so a backlog near 3.5 GB leaves room for bursts. The numbers here are arithmetic, not a recommendation for your workload.
  4. Check memory. The backlog is memory on the primary on top of the dataset, so confirm maxmemory still fits.

Afterwards compare repl_backlog_histlen with repl_backlog_size. When the history is always full and sync_full keeps climbing, the backlog is too small.

Why does a full sync loop?

A full sync takes a snapshot and sends it. By default repl-diskless-sync is yes and repl-diskless-sync-delay is 5 seconds, so the primary waits briefly for more replicas to join before it forks. While the snapshot transfers, the primary keeps buffering new writes for that replica. The default client-output-buffer-limit replica 256mb 64mb 60 means a hard limit of 256mb, or a soft limit of 64mb held for 60 seconds. If either trips, the primary closes the connection, and the replica must begin again. The valkey.conf comments add that a replica limit smaller than repl-backlog-size is ignored and the backlog size is used.

A slow fork makes it worse. latest_fork_usec in INFO stats shows how long the last fork took, in microseconds. A large dataset on a busy host can take long enough that the buffer fills before the snapshot is even sent.

INFO fieldSectionWhat it tells you
master_repl_offsetreplicationBytes written; sample twice for the write rate
repl_backlog_sizereplicationConfigured backlog size
repl_backlog_histlenreplicationHow much history the backlog holds now
repl_backlog_first_byte_offsetreplicationOldest offset a replica can still resume from
sync_fullstatsCount of full resyncs; rising means loops
sync_partial_ok / sync_partial_errstatsPartial resyncs accepted or refused
latest_fork_usecstatsDuration of the last fork

What are the options if the loop continues?

  • Raise client-output-buffer-limit replica to cover the writes made during one snapshot transfer.
  • Reduce write traffic during planned resyncs, for example by pausing a batch job.
  • Try dual-channel replication. dual-channel-replication-enabled is documented from Valkey 8.0, defaults to no and must be yes on both primary and replica. The replica receives the snapshot on one connection and buffers the write stream itself. Test it first on a non-production pair.
  • Sample on a schedule. Alert when sync_full rises and when repl_backlog_histlen stays equal to repl_backlog_size.

Memory pressure while moving data is a related problem, covered in our Valkey memory pressure remediation use case.

Sources

  • Replication, valkey.io, read 3 December 2026.
  • valkey.conf, valkey-io/valkey on GitHub, read 3 December 2026.
  • INFO, valkey.io, read 3 December 2026.

Frequently Asked Questions

Why does my Valkey replica keep doing a full resync?

A partial resync works only while the replica's offset is still inside the primary's backlog. With the default 10mb repl-backlog-size, a busy primary overwrites that history quickly, so a short disconnect can force a full resync. Raise the backlog to cover write rate times the longest outage.

How big should repl-backlog-size be?

Multiply the primary's write rate in bytes per second by the longest disconnect you want a partial resync to survive, then add headroom. Measure the write rate by sampling master_repl_offset twice and dividing the difference by the seconds between samples.

What causes a full resync loop?

The sync starts, the primary buffers new writes for the replica, and the buffer passes client-output-buffer-limit replica. The primary drops the link and the replica has to begin the sync again. Raise the limit, reduce write traffic during the sync, or try dual-channel replication.

Scott Sternloff

Author

Scott SternloffSenior Enterprise Architect

Senior Enterprise Architect at AceMQ. Writes the technical coverage here: RabbitMQ, Kafka and Redis architecture, clustering and migrations.

Talk to an engineer

Need a hand with Valkey?

Senior engineers who run it in production. Get a quote or a free consultation, no sales pitch.

Free Consultation

Get Expert Eyes on Your Valkey Environment

Whether you're troubleshooting a production incident, planning a migration, or want a second opinion on your architecture — our team is ready. No pitch, just answers.

Email Us