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

Function sentinelCheckObjectivelyDown

src/sentinel.cpp:4252–4285  ·  view source on GitHub ↗

Is this instance down according to the configured quorum? * * Note that ODOWN is a weak quorum, it only means that enough Sentinels * reported in a given time range that the instance was not reachable. * However messages can be delayed so there are no strong guarantees about * N instances agreeing at the same time about the down state. */

Source from the content-addressed store, hash-verified

4250 * However messages can be delayed so there are no strong guarantees about
4251 * N instances agreeing at the same time about the down state. */
4252void sentinelCheckObjectivelyDown(sentinelRedisInstance *master) {
4253 dictIterator *di;
4254 dictEntry *de;
4255 unsigned int quorum = 0, odown = 0;
4256
4257 if (master->flags & SRI_S_DOWN) {
4258 /* Is down for enough sentinels? */
4259 quorum = 1; /* the current sentinel. */
4260 /* Count all the other sentinels. */
4261 di = dictGetIterator(master->sentinels);
4262 while((de = dictNext(di)) != NULL) {
4263 sentinelRedisInstance *ri = (sentinelRedisInstance*)dictGetVal(de);
4264
4265 if (ri->flags & SRI_MASTER_DOWN) quorum++;
4266 }
4267 dictReleaseIterator(di);
4268 if (quorum >= master->quorum) odown = 1;
4269 }
4270
4271 /* Set the flag accordingly to the outcome. */
4272 if (odown) {
4273 if ((master->flags & SRI_O_DOWN) == 0) {
4274 sentinelEvent(LL_WARNING,"+odown",master,"%@ #quorum %d/%d",
4275 quorum, master->quorum);
4276 master->flags |= SRI_O_DOWN;
4277 master->o_down_since_time = mstime();
4278 }
4279 } else {
4280 if (master->flags & SRI_O_DOWN) {
4281 sentinelEvent(LL_WARNING,"-odown",master,"%@");
4282 master->flags &= ~SRI_O_DOWN;
4283 }
4284 }
4285}
4286
4287/* Receive the SENTINEL is-master-down-by-addr reply, see the
4288 * sentinelAskMasterStateToOtherSentinels() function for more information. */

Callers 1

Calls 5

sentinelEventFunction · 0.85
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70
mstimeFunction · 0.70

Tested by

no test coverage detected