Commit eec769be authored by zhaozhao.zz's avatar zhaozhao.zz
Browse files

PSYNC2: second_replid_offset should be real meaningful offset

After adjustMeaningfulReplOffset(), all the other related variable
should be updated, including server.second_replid_offset.

Or the old version redis like 5.0 may receive wrong data from
replication stream, cause redis 5.0 can sync with redis 6.0,
but doesn't know meaningful offset.
parent b89e6d74
...@@ -2531,14 +2531,14 @@ void replicationUnsetMaster(void) { ...@@ -2531,14 +2531,14 @@ void replicationUnsetMaster(void) {
sdsfree(server.masterhost); sdsfree(server.masterhost);
server.masterhost = NULL; server.masterhost = NULL;
if (server.master) freeClient(server.master);
replicationDiscardCachedMaster();
cancelReplicationHandshake();
/* When a slave is turned into a master, the current replication ID /* When a slave is turned into a master, the current replication ID
* (that was inherited from the master at synchronization time) is * (that was inherited from the master at synchronization time) is
* used as secondary ID up to the current offset, and a new replication * used as secondary ID up to the current offset, and a new replication
* ID is created to continue with a new replication history. */ * ID is created to continue with a new replication history. */
shiftReplicationId(); shiftReplicationId();
if (server.master) freeClient(server.master);
replicationDiscardCachedMaster();
cancelReplicationHandshake();
/* Disconnecting all the slaves is required: we need to inform slaves /* Disconnecting all the slaves is required: we need to inform slaves
* of the replication ID change (see shiftReplicationId() call). However * of the replication ID change (see shiftReplicationId() call). However
* the slaves will be able to partially resync with us, so it will be * the slaves will be able to partially resync with us, so it will be
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment