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

Function refreshGoodSlavesCount

src/replication.cpp:4496–4513  ·  view source on GitHub ↗

This function counts the number of slaves with lag <= min-slaves-max-lag. * If the option is active, the server will prevent writes if there are not * enough connected slaves with the specified lag (or less). */

Source from the content-addressed store, hash-verified

4494 * If the option is active, the server will prevent writes if there are not
4495 * enough connected slaves with the specified lag (or less). */
4496void refreshGoodSlavesCount(void) {
4497 listIter li;
4498 listNode *ln;
4499 int good = 0;
4500
4501 if (!g_pserver->repl_min_slaves_to_write ||
4502 !g_pserver->repl_min_slaves_max_lag) return;
4503
4504 listRewind(g_pserver->slaves,&li);
4505 while((ln = listNext(&li))) {
4506 client *replica = (client*)ln->value;
4507 time_t lag = g_pserver->unixtime - replica->repl_ack_time;
4508
4509 if (replica->replstate == SLAVE_STATE_ONLINE &&
4510 lag <= g_pserver->repl_min_slaves_max_lag) good++;
4511 }
4512 g_pserver->repl_good_slaves_count = good;
4513}
4514
4515/* ----------------------- REPLICATION SCRIPT CACHE --------------------------
4516 * The goal of this code is to keep track of scripts already sent to every

Callers 5

putSlaveOnlineFunction · 0.85
replicationCronFunction · 0.85
updateGoodSlavesFunction · 0.85
freeClientFunction · 0.85

Calls 2

listRewindFunction · 0.85
listNextFunction · 0.85

Tested by

no test coverage detected