Merge pull request #7320 from soloestoy/second-replid-offset-should-be-meaningful-offset

PSYNC2: second_replid_offset should be real meaningful offset
This commit is contained in:
Salvatore Sanfilippo 2020-05-25 11:37:25 +02:00 committed by GitHub
commit 9e055a0f1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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