MCPcopy Create free account
hub / github.com/F-Stack/f-stack / refreshGoodSlavesCount

Function refreshGoodSlavesCount

app/redis-6.2.6/src/replication.c:3029–3046  ·  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

3027 * If the option is active, the server will prevent writes if there are not
3028 * enough connected slaves with the specified lag (or less). */
3029void refreshGoodSlavesCount(void) {
3030 listIter li;
3031 listNode *ln;
3032 int good = 0;
3033
3034 if (!server.repl_min_slaves_to_write ||
3035 !server.repl_min_slaves_max_lag) return;
3036
3037 listRewind(server.slaves,&li);
3038 while((ln = listNext(&li))) {
3039 client *slave = ln->value;
3040 time_t lag = server.unixtime - slave->repl_ack_time;
3041
3042 if (slave->replstate == SLAVE_STATE_ONLINE &&
3043 lag <= server.repl_min_slaves_max_lag) good++;
3044 }
3045 server.repl_good_slaves_count = good;
3046}
3047
3048/* ----------------------- REPLICATION SCRIPT CACHE --------------------------
3049 * The goal of this code is to keep track of scripts already sent to every

Callers 5

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

Calls 2

listRewindFunction · 0.85
listNextFunction · 0.85

Tested by

no test coverage detected