MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sentinelFailoverSendSlaveOfNoOne

Function sentinelFailoverSendSlaveOfNoOne

src/sentinel.cpp:4802–4826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4800}
4801
4802void sentinelFailoverSendSlaveOfNoOne(sentinelRedisInstance *ri) {
4803 int retval;
4804
4805 /* We can't send the command to the promoted slave if it is now
4806 * disconnected. Retry again and again with this state until the timeout
4807 * is reached, then abort the failover. */
4808 if (ri->promoted_slave->link->disconnected) {
4809 if (mstime() - ri->failover_state_change_time > ri->failover_timeout) {
4810 sentinelEvent(LL_WARNING,"-failover-abort-slave-timeout",ri,"%@");
4811 sentinelAbortFailover(ri);
4812 }
4813 return;
4814 }
4815
4816 /* Send SLAVEOF NO ONE command to turn the slave into a master.
4817 * We actually register a generic callback for this command as we don't
4818 * really care about the reply. We check if it worked indirectly observing
4819 * if INFO returns a different role (master instead of slave). */
4820 retval = sentinelSendSlaveOf(ri->promoted_slave,NULL);
4821 if (retval != C_OK) return;
4822 sentinelEvent(LL_NOTICE, "+failover-state-wait-promotion",
4823 ri->promoted_slave,"%@");
4824 ri->failover_state = SENTINEL_FAILOVER_STATE_WAIT_PROMOTION;
4825 ri->failover_state_change_time = mstime();
4826}
4827
4828/* We actually wait for promotion indirectly checking with INFO when the
4829 * slave turns into a master. */

Callers 1

Calls 4

sentinelEventFunction · 0.85
sentinelAbortFailoverFunction · 0.85
sentinelSendSlaveOfFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected