Databases

Redis replica stops applying updates after RDB mismatch during BGSAVE causing replication gap and growing replication backlog

theocode
1mo ago
Environment

Environment

Primary Redis 6.2 on Linux performing scheduled BGSAVE during peak load; replica Redis instances on separate hosts connect with replicaof and 'repl-backlog-size' default; one replica now shows a replication gap and reports mismatch on RDB checksum.

Symptoms

Symptoms

Replica reports 'RDB checksum mismatch' and stops applying subsequent replication stream; replication offset diverges and replication backlog grows; reads from replica stale. No other errors on network layer.

Observations

Observations

Primary logs show BGSAVE spawned and completed with an RDB file checksum X; replica log shows expected RDB checksum Y and then disconnects. Replica's last-disk snapshot timestamp differs. Attempting PSYNC fails with '-ERR RDB checksum mismatch'.

Already attempted

Already attempted

Tried 'REPLICAOF partial resync' commands, restarted replica, cleared AOF (none in use), attempted to force full sync but PSYNC continues to reject due to checksum mismatch. Finally performed full stop of replica and delete of dump.rdb then restart to force new sync — that triggered a full resync and restored replication but requires replica downtime.

Question

Question

What's the safest way to recover replicas after RDB checksum mismatch without causing data corruption or extended downtime, and how to avoid recurring mismatch during BGSAVE under load?

COMMUNITY RESPONSES

Verified community troubleshooting

1 reply
0
aliceadmin Answer
user
Posted 1mo ago • 0 confirmations

A mismatch usually means the replica's RDB isn't the same as the primary's snapshot. Safest recovery is to stop the replica, delete its dump.rdb (and AOF if you use it), then restart so it pulls a fresh RDB from the primary. Before doing that, check primary dmesg and disk SMART for I/O errors during the BGSAVE time—if the primary’s RDB was corrupted you'll see evidence there and should fix storage first. This approach forces a full resync and is reversible by restoring the deleted files from backup if needed.

Showing 1 of 1 community responses
AI DIAGNOSTICS

Incident analysis

Updated 1mo ago• Trouble ID

Most likely causes

RDB file produced by primary was corrupted during BGSAVE due to disk I/O starvation or kernel OOM killing RDB writer child 70%
Network corruption or intermediary proxy mangled the RDB transfer causing checksum mismatch on replica during replication 35%
Replica had stale dump.rdb or leftover metadata interfering with PSYNC runid/offset negotiation 30%

Summary

An RDB checksum mismatch indicates the replica received an RDB that doesn't match the primary's expected checksum—common causes: primary's BGSAVE produced a corrupted/split RDB written mid-rise (e.g., disk IO issues), network corruption during transfer, or replica data leftover causing mismatch on PSYNC. Redis PSYNC compares runid and offset; if mismatch it requires full resync. Safe recovery is to remove the stale dump.rdb on replica to force a fresh copy from primary (as done), but prevention involves ensuring BGSAVE completes atomically (reliable storage, disable aggressive OOM killer), or moving snapshots to reliable disks and enabling fsync protections. Large memory sets or disk saturation can cause partial writes. Consider enabling TLS checksums and monitoring disk I/O and dmesg for errors.

Suggested Fixes

Diagnostic step 1
To recover safely: stop the replica Redis, remove dump.rdb and appendonly.aof (if present), then start the replica so it triggers a clean full sync from primary (ensure you have backups and that this replica is not the authoritative source).
Diagnostic step 2
Check primary dmesg and system logs for IO errors at BGSAVE time and verify disk SMART health; move RDB directory to a reliable filesystem if issues found.
Diagnostic step 3
If BGSAVE corruption suspected, schedule saves during low load or enable RDB file atomic write protections (use tmp file rename behavior) and consider upgrading to a Redis version with known fixes.

Continue troubleshooting

Matched from the title, description and tags