Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Test log based replication(AOF PSYNC)

tonyxia edited this page Dec 22, 2017 · 2 revisions
  • Create two Redis instance A and B.
  • Configuration:
config set appendonly yes
config set aof-psync-state yes
  • make B as a slave of A.
  • set A's repl-backlog-size to 1mb, smaller backlog size can reproduce the following situation easier.
  • start write pressure on A in the background.
redis-benchmark -h A_ip -p A_port -a xxx -d 128 -t set -r 10000000 -n 10000 -c 10 -l
  • use iptables or tc to simulate network failure between A and B for 10 seconds.
  • kill slave client on A by using client kill command.
  • after 10 seconds, B will reconnect with A as a slave. Because of lack of backlog, A will try an aof psync, read the binlog from disk and send it to B.
  • On A and B, we can see logs like this:
A(master log):
[12750] 22 Jun 14:12:29.380 * Slave xxx:3068 asks for synchronization
[12750] 22 Jun 14:12:29.380 * Unable to partial resync with slave xxx:3068 for lack of backlog (Slave request was: 2103130688).
[12750] 22 Jun 14:12:29.380 * master try aof psync, recieved slave next opid: 5924288
[12750] 22 Jun 14:12:29.380 * getAofFirstOpid: parsed first opid 0 in appendonly-inc-1498037916.aof
[12750] 22 Jun 14:12:29.380 * master try aof psync, master minimum opid: 0, slave next opid: 5924288, master next opid: 5960001
[12750] 22 Jun 14:12:29.380 * master start aof partial resynchronization requested by xxx:3068
...
[12750] 22 Jun 14:12:30.137 * offset found for slave_next_opid(5924288): appendonly-inc-1498111941.aof:94278060
[12750] 22 Jun 14:12:30.554 * appendonly-inc-1498111941.aof read done, finding next aof
[12750] 22 Jun 14:12:31.579 * final aof appendonly-inc-1498111949.aof read done
[12750] 22 Jun 14:12:31.579 * Synchronization with slave xxx:3068 succeeded

slave log:
[104313] 22 Jun 14:12:29.378 * Connecting to MASTER 10.218.144.111:3068
[104313] 22 Jun 14:12:29.379 * MASTER <-> SLAVE sync started
[104313] 22 Jun 14:12:29.379 * Non blocking connect for SYNC fired the event.
[104313] 22 Jun 14:12:29.379 * Master replied to PING, replication can continue...
[104313] 22 Jun 14:12:29.380 * Trying a partial resynchronization (request 7ddf958e7848b4044809b109a4509c4022d65526:2103130688).
[104313] 22 Jun 14:12:29.380 * slave syschronously send command to master: (PSYNC master_runid psync_offset slave_next_opid)(PSYNC 7ddf958e7848b4044809b109a4509c4022d65526 2103130688 5924288)
[104313] 22 Jun 14:12:29.380 * aof psync from master: 7ddf958e7848b4044809b109a4509c4022d65526
[104313] 22 Jun 14:12:29.380 * Discarding previously cached master state.
[104313] 22 Jun 14:12:29.380 * MASTER <-> SLAVE sync: Master accepted a Partial Resynchronization.
[104313] 22 Jun 14:12:31.582 * sync repl offset with master: 2145858146
Clone this wiki locally