Use the current replication ID / offset as secondary replication * ID, and change the current one in order to start a new history. * This should be used when an instance is switched from slave to master * so that it can serve PSYNC requests performed using the master * replication ID. */
| 1401 | * so that it can serve PSYNC requests performed using the master |
| 1402 | * replication ID. */ |
| 1403 | void shiftReplicationId(void) { |
| 1404 | memcpy(server.replid2,server.replid,sizeof(server.replid)); |
| 1405 | /* We set the second replid offset to the master offset + 1, since |
| 1406 | * the slave will ask for the first byte it has not yet received, so |
| 1407 | * we need to add one to the offset: for example if, as a slave, we are |
| 1408 | * sure we have the same history as the master for 50 bytes, after we |
| 1409 | * are turned into a master, we can accept a PSYNC request with offset |
| 1410 | * 51, since the slave asking has the same history up to the 50th |
| 1411 | * byte, and is asking for the new bytes starting at offset 51. */ |
| 1412 | server.second_replid_offset = server.master_repl_offset+1; |
| 1413 | changeReplicationId(); |
| 1414 | serverLog(LL_WARNING,"Setting secondary replication ID to %s, valid up to offset: %lld. New replication ID is %s", server.replid2, server.second_replid_offset, server.replid); |
| 1415 | } |
| 1416 | |
| 1417 | /* ----------------------------------- SLAVE -------------------------------- */ |
| 1418 |
no test coverage detected