Error: Replication sync failed, replica id mismatch, expected <replica_id> but got <replica_id>
ID: redis/sync-replica-id-mismatch
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 6.2.0 | active | — | — | — |
| 7.0.0 | active | — | — | — |
| 7.2.0 | active | — | — | — |
| 7.4.0 | active | — | — | — |
Root Cause
During partial resynchronization, the replica's cached master replication ID does not match the current master's replication ID, often due to master restart or failover.
generic中文
在部分重新同步期间,副本缓存的master复制ID与当前master的复制ID不匹配,通常是由于master重启或故障转移导致。
Official Documentation
https://redis.io/docs/management/replication/Workarounds
-
95% success On the replica, run `SLAVEOF NO ONE` then `SLAVEOF <master_ip> <master_port>` to force a full resynchronization.
On the replica, run `SLAVEOF NO ONE` then `SLAVEOF <master_ip> <master_port>` to force a full resynchronization.
-
85% success If using Redis Sentinel, trigger a manual failover: `redis-cli -p 26379 SENTINEL failover <mymaster>` to elect a new master and force replicas to sync with a fresh replication ID.
If using Redis Sentinel, trigger a manual failover: `redis-cli -p 26379 SENTINEL failover <mymaster>` to elect a new master and force replicas to sync with a fresh replication ID.
-
90% success In a cluster environment, use `CLUSTER REPLICATE <node-id>` on the replica after ensuring the master is healthy and has a consistent replication ID.
In a cluster environment, use `CLUSTER REPLICATE <node-id>` on the replica after ensuring the master is healthy and has a consistent replication ID.
中文步骤
在副本上运行 `SLAVEOF NO ONE` 然后 `SLAVEOF <master_ip> <master_port>` 以强制完全重新同步。
如果使用Redis Sentinel,触发手动故障转移:`redis-cli -p 26379 SENTINEL failover <mymaster>` 以选举新的master并强制副本使用新的复制ID同步。
在集群环境中,确保master健康且复制ID一致后,在副本上使用 `CLUSTER REPLICATE <node-id>`。
Dead Ends
Common approaches that don't work:
-
75% fail
Restarting the replica without clearing its replication backlog or ID cache does not fix the underlying mismatch; the replica will retry with the same stale ID.
-
90% fail
Manually setting repl-id using CONFIG SET on the master is risky and may break replication for other replicas; it does not address the root cause of ID divergence.
-
80% fail
Increasing repl-backlog-size on the master alone does not resolve a mismatched replication ID; the replica must perform a full sync to reset the ID.