Send SLAVE OF to all the remaining slaves that * still don't appear to have the configuration updated. */
| 4900 | /* Send SLAVE OF <new master address> to all the remaining slaves that |
| 4901 | * still don't appear to have the configuration updated. */ |
| 4902 | void sentinelFailoverReconfNextSlave(sentinelRedisInstance *master) { |
| 4903 | dictIterator *di; |
| 4904 | dictEntry *de; |
| 4905 | int in_progress = 0; |
| 4906 | serverAssert(GlobalLocksAcquired()); |
| 4907 | |
| 4908 | di = dictGetIterator(master->slaves); |
| 4909 | while((de = dictNext(di)) != NULL) { |
| 4910 | sentinelRedisInstance *slave = (sentinelRedisInstance*)dictGetVal(de); |
| 4911 | |
| 4912 | if (slave->flags & (SRI_RECONF_SENT|SRI_RECONF_INPROG)) |
| 4913 | in_progress++; |
| 4914 | } |
| 4915 | dictReleaseIterator(di); |
| 4916 | |
| 4917 | di = dictGetIterator(master->slaves); |
| 4918 | while(in_progress < master->parallel_syncs && |
| 4919 | (de = dictNext(di)) != NULL) |
| 4920 | { |
| 4921 | sentinelRedisInstance *slave = (sentinelRedisInstance*)dictGetVal(de); |
| 4922 | int retval; |
| 4923 | |
| 4924 | /* Skip the promoted slave, and already configured slaves. */ |
| 4925 | if (slave->flags & (SRI_PROMOTED|SRI_RECONF_DONE)) continue; |
| 4926 | |
| 4927 | /* If too much time elapsed without the slave moving forward to |
| 4928 | * the next state, consider it reconfigured even if it is not. |
| 4929 | * Sentinels will detect the slave as misconfigured and fix its |
| 4930 | * configuration later. */ |
| 4931 | if ((slave->flags & SRI_RECONF_SENT) && |
| 4932 | (mstime() - slave->slave_reconf_sent_time) > |
| 4933 | SENTINEL_SLAVE_RECONF_TIMEOUT) |
| 4934 | { |
| 4935 | sentinelEvent(LL_NOTICE,"-slave-reconf-sent-timeout",slave,"%@"); |
| 4936 | slave->flags &= ~SRI_RECONF_SENT; |
| 4937 | slave->flags |= SRI_RECONF_DONE; |
| 4938 | } |
| 4939 | |
| 4940 | /* Nothing to do for instances that are disconnected or already |
| 4941 | * in RECONF_SENT state. */ |
| 4942 | if (slave->flags & (SRI_RECONF_SENT|SRI_RECONF_INPROG)) continue; |
| 4943 | if (slave->link->disconnected) continue; |
| 4944 | |
| 4945 | /* Send SLAVEOF <new master>. */ |
| 4946 | retval = sentinelSendSlaveOf(slave,master->promoted_slave->addr); |
| 4947 | if (retval == C_OK) { |
| 4948 | slave->flags |= SRI_RECONF_SENT; |
| 4949 | slave->slave_reconf_sent_time = mstime(); |
| 4950 | sentinelEvent(LL_NOTICE,"+slave-reconf-sent",slave,"%@"); |
| 4951 | in_progress++; |
| 4952 | } |
| 4953 | } |
| 4954 | dictReleaseIterator(di); |
| 4955 | |
| 4956 | /* Check if all the slaves are reconfigured and handle timeout. */ |
| 4957 | sentinelFailoverDetectEnd(master); |
| 4958 | } |
| 4959 |
no test coverage detected