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. */
| 4238 | * However messages can be delayed so there are no strong guarantees about |
| 4239 | * N instances agreeing at the same time about the down state. */ |
| 4240 | void sentinelCheckObjectivelyDown(sentinelRedisInstance *master) { |
| 4241 | dictIterator *di; |
| 4242 | dictEntry *de; |
| 4243 | unsigned int quorum = 0, odown = 0; |
| 4244 | |
| 4245 | if (master->flags & SRI_S_DOWN) { |
| 4246 | /* Is down for enough sentinels? */ |
| 4247 | quorum = 1; /* the current sentinel. */ |
| 4248 | /* Count all the other sentinels. */ |
| 4249 | di = dictGetIterator(master->sentinels); |
| 4250 | while((de = dictNext(di)) != NULL) { |
| 4251 | sentinelRedisInstance *ri = dictGetVal(de); |
| 4252 | |
| 4253 | if (ri->flags & SRI_MASTER_DOWN) quorum++; |
| 4254 | } |
| 4255 | dictReleaseIterator(di); |
| 4256 | if (quorum >= master->quorum) odown = 1; |
| 4257 | } |
| 4258 | |
| 4259 | /* Set the flag accordingly to the outcome. */ |
| 4260 | if (odown) { |
| 4261 | if ((master->flags & SRI_O_DOWN) == 0) { |
| 4262 | sentinelEvent(LL_WARNING,"+odown",master,"%@ #quorum %d/%d", |
| 4263 | quorum, master->quorum); |
| 4264 | master->flags |= SRI_O_DOWN; |
| 4265 | master->o_down_since_time = mstime(); |
| 4266 | } |
| 4267 | } else { |
| 4268 | if (master->flags & SRI_O_DOWN) { |
| 4269 | sentinelEvent(LL_WARNING,"-odown",master,"%@"); |
| 4270 | master->flags &= ~SRI_O_DOWN; |
| 4271 | } |
| 4272 | } |
| 4273 | } |
| 4274 | |
| 4275 | /* Receive the SENTINEL is-master-down-by-addr reply, see the |
| 4276 | * sentinelAskMasterStateToOtherSentinels() function for more information. */ |
no test coverage detected