This function is called when the slave lose the connection with the * master into an unexpected way. */
| 2721 | /* This function is called when the slave lose the connection with the |
| 2722 | * master into an unexpected way. */ |
| 2723 | void replicationHandleMasterDisconnection(void) { |
| 2724 | /* Fire the master link modules event. */ |
| 2725 | if (server.repl_state == REPL_STATE_CONNECTED) |
| 2726 | moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, |
| 2727 | REDISMODULE_SUBEVENT_MASTER_LINK_DOWN, |
| 2728 | NULL); |
| 2729 | |
| 2730 | server.master = NULL; |
| 2731 | server.repl_state = REPL_STATE_CONNECT; |
| 2732 | server.repl_down_since = server.unixtime; |
| 2733 | /* We lost connection with our master, don't disconnect slaves yet, |
| 2734 | * maybe we'll be able to PSYNC with our master later. We'll disconnect |
| 2735 | * the slaves only if we'll have to do a full resync with our master. */ |
| 2736 | |
| 2737 | /* Try to re-connect immediately rather than wait for replicationCron |
| 2738 | * waiting 1 second may risk backlog being recycled. */ |
| 2739 | if (server.masterhost) { |
| 2740 | serverLog(LL_NOTICE,"Reconnecting to MASTER %s:%d", |
| 2741 | server.masterhost, server.masterport); |
| 2742 | connectWithMaster(); |
| 2743 | } |
| 2744 | } |
| 2745 | |
| 2746 | void replicaofCommand(client *c) { |
| 2747 | /* SLAVEOF is not allowed in cluster mode as replication is automatically |
no test coverage detected