mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Diskless replication: trigger diskless RDB transfer if needed.
This commit is contained in:
parent
3730d118a3
commit
e9e007555e
@ -115,7 +115,7 @@ typedef long long mstime_t; /* millisecond time type. */
|
|||||||
#define REDIS_DEFAULT_RDB_CHECKSUM 1
|
#define REDIS_DEFAULT_RDB_CHECKSUM 1
|
||||||
#define REDIS_DEFAULT_RDB_FILENAME "dump.rdb"
|
#define REDIS_DEFAULT_RDB_FILENAME "dump.rdb"
|
||||||
#define REDIS_DEFAULT_RDB_DISKLESS 0
|
#define REDIS_DEFAULT_RDB_DISKLESS 0
|
||||||
#define REIDS_DEFAULT_RDB_DISKLESS_DELAY 5
|
#define REDIS_DEFAULT_RDB_DISKLESS_DELAY 5
|
||||||
#define REDIS_DEFAULT_SLAVE_SERVE_STALE_DATA 1
|
#define REDIS_DEFAULT_SLAVE_SERVE_STALE_DATA 1
|
||||||
#define REDIS_DEFAULT_SLAVE_READ_ONLY 1
|
#define REDIS_DEFAULT_SLAVE_READ_ONLY 1
|
||||||
#define REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY 0
|
#define REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY 0
|
||||||
|
@ -212,7 +212,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write the command to every slave. */
|
/* Write the command to every slave. */
|
||||||
listRewind(slaves,&li);
|
listRewind(server.slaves,&li);
|
||||||
while((ln = listNext(&li))) {
|
while((ln = listNext(&li))) {
|
||||||
redisClient *slave = ln->value;
|
redisClient *slave = ln->value;
|
||||||
|
|
||||||
@ -1941,6 +1941,41 @@ void replicationCron(void) {
|
|||||||
replicationScriptCacheFlush();
|
replicationScriptCacheFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we are using diskless replication and there are slaves waiting
|
||||||
|
* in WAIT_BGSAVE_START state, check if enough seconds elapsed and
|
||||||
|
* start one. */
|
||||||
|
if (server.repl_diskless && server.rdb_child_pid == -1 &&
|
||||||
|
server.aof_child_pid == -1)
|
||||||
|
{
|
||||||
|
time_t idle, max_idle = 0;
|
||||||
|
int slaves_waiting = 0;
|
||||||
|
listNode *ln;
|
||||||
|
listIter li;
|
||||||
|
|
||||||
|
listRewind(server.slaves,&li);
|
||||||
|
while((ln = listNext(&li))) {
|
||||||
|
redisClient *slave = ln->value;
|
||||||
|
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) {
|
||||||
|
idle = server.unixtime - slave->lastinteraction;
|
||||||
|
if (idle > max_idle) max_idle = idle;
|
||||||
|
slaves_waiting++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slaves_waiting && max_idle > REDIS_DEFAULT_RDB_DISKLESS_DELAY) {
|
||||||
|
/* Let's start a BGSAVE with disk target. */
|
||||||
|
if (startBgsaveForReplication() == REDIS_OK) {
|
||||||
|
/* It started! We need to change the state of slaves
|
||||||
|
* from WAIT_BGSAVE_START to WAIT_BGSAVE_END. */
|
||||||
|
while((ln = listNext(&li))) {
|
||||||
|
redisClient *slave = ln->value;
|
||||||
|
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START)
|
||||||
|
slave->replstate = REDIS_REPL_WAIT_BGSAVE_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Refresh the number of slaves with lag <= min-slaves-max-lag. */
|
/* Refresh the number of slaves with lag <= min-slaves-max-lag. */
|
||||||
refreshGoodSlavesCount();
|
refreshGoodSlavesCount();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user