MCPcopy Create free account
hub / github.com/F-Stack/f-stack / replicationHandleMasterDisconnection

Function replicationHandleMasterDisconnection

app/redis-6.2.6/src/replication.c:2723–2744  ·  view source on GitHub ↗

This function is called when the slave lose the connection with the * master into an unexpected way. */

Source from the content-addressed store, hash-verified

2721/* This function is called when the slave lose the connection with the
2722 * master into an unexpected way. */
2723void 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
2746void replicaofCommand(client *c) {
2747 /* SLAVEOF is not allowed in cluster mode as replication is automatically

Callers 2

replicationCacheMasterFunction · 0.85
freeClientFunction · 0.85

Calls 2

moduleFireServerEventFunction · 0.85
connectWithMasterFunction · 0.85

Tested by

no test coverage detected