Our application is deployed in two different environments (Env - 1 & Env - 2). Both environments will have two nodes master and replica.

 Env - 1                                               Env - 2
+ + + + + + + + + + + + + + + + +        + + + + + + + + + + + + + + + + +    
| MASTER - - - - - - -> REPLICA |  --->  | MASTER - - - - - - -> REPLICA | 
+ + + + + + + + + + + + + + + + +        + + + + + + + + + + + + + + + + +    

Initially, the redis replication will be configured from the Env - 1 (R) Node to Env - 2 (M) Node.

There will be a case to reverse the replication. To achieve this, we will break the replication and then reconfigure the replication between the Env - 2 (R) Node to Env - 1 (M) Node. During this, redis servers (Env - 1) couldn't complete the partial resync. (logs below)

Reason for the failure :

  1. Once we break the replication (replicaof no one) for Env - 2 (M) Node. Then new master_replid getting generated and older master_replid & master_repl_offset shifted to master_replid2 & second_repl_offset.
  2. Still, the Env - 1 (R) node receives PINGs from the old master of Env - 1 (M) node in the configured interval (repl-ping-replica-period)
  3. Due to the PINGs in Env - 1 master & replica node offset getting incremented which causing a mismatch so the partial resync failed.

The full resync is expensive. How can we avoid? Any other possible solution for this case?

Env - 2 (Replica) Node

Replica xxx.xx.xx.xx:6379 asks for synchronization Partial resynchronization not accepted: Requested offset for second ID was 21415514, but I can reply up to 21415500 Starting BGSAVE for SYNC with target: disk Background saving started by pid 7790 Background saving terminated with success Synchronization with replica xxx.xx.xx.xx:6379 succeeded

Env - 1 (Master) Node

Trying a partial resynchronization (request 1ad7e56ef10178e3a0be05ebb58f90b7668223a4:21415514). Full resync from master: f3950935a9ed1da5c10f77b5ccbd7868767e59ea:21415513 Discarding previously cached master state. MASTER <-> REPLICA sync: receiving 2057 bytes from master MASTER <-> REPLICA sync: Flushing old data MASTER <-> REPLICA sync: Loading DB in memory MASTER <-> REPLICA sync: Finished with success

Comment From: itamarhaber

Hello @ganeshkumarganesan

Keep in mind that this issue tracker should be used for reporting bugs or proposing improvements to the Redis server. This appears to be a deployment question, so kindly close it.

Questions should be directed to the community: