mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Diskless replication: trigger a BGSAVE after a config change.
If we turn from diskless to disk-based replication via CONFIG SET, we need a way to start a BGSAVE if there are slaves alerady waiting for a BGSAVE to start. Normally with disk-based replication we do it as soon as the previous child exits, but when there is a configuration change via CONFIG SET, we may have slaves in WAIT_BGSAVE_START state without an RDB background process currently active.
This commit is contained in:
parent
5f8360eb21
commit
42951ab301
@ -689,17 +689,20 @@ void sendBulkToSlave(aeEventLoop *el, int fd, void *privdata, int mask) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is called at the end of every background saving.
|
/* This function is called at the end of every background saving,
|
||||||
* The argument bgsaveerr is REDIS_OK if the background saving succeeded
|
* or when the replication RDB transfer strategy is modified from
|
||||||
* otherwise REDIS_ERR is passed to the function.
|
* disk to socket or the other way around.
|
||||||
* The 'type' argument is the type of the child that terminated
|
|
||||||
* (if it had a disk or socket target).
|
|
||||||
*
|
*
|
||||||
* The goal of this function is to handle slaves waiting for a successful
|
* The goal of this function is to handle slaves waiting for a successful
|
||||||
* background saving in order to perform non-blocking synchronization, and
|
* background saving in order to perform non-blocking synchronization, and
|
||||||
* to schedule a new BGSAVE if there are slaves that attached while a
|
* to schedule a new BGSAVE if there are slaves that attached while a
|
||||||
* BGSAVE was in progress, but it was not a good one for replication (no
|
* BGSAVE was in progress, but it was not a good one for replication (no
|
||||||
* other slave was accumulating differences). */
|
* other slave was accumulating differences).
|
||||||
|
*
|
||||||
|
* The argument bgsaveerr is REDIS_OK if the background saving succeeded
|
||||||
|
* otherwise REDIS_ERR is passed to the function.
|
||||||
|
* The 'type' argument is the type of the child that terminated
|
||||||
|
* (if it had a disk or socket target). */
|
||||||
void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
|
void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
|
||||||
listNode *ln;
|
listNode *ln;
|
||||||
int startbgsave = 0;
|
int startbgsave = 0;
|
||||||
@ -1943,10 +1946,12 @@ void replicationCron(void) {
|
|||||||
|
|
||||||
/* If we are using diskless replication and there are slaves waiting
|
/* If we are using diskless replication and there are slaves waiting
|
||||||
* in WAIT_BGSAVE_START state, check if enough seconds elapsed and
|
* in WAIT_BGSAVE_START state, check if enough seconds elapsed and
|
||||||
* start one. */
|
* start a BGSAVE.
|
||||||
if (server.repl_diskless_sync && server.rdb_child_pid == -1 &&
|
*
|
||||||
server.aof_child_pid == -1)
|
* This code is also useful to trigger a BGSAVE if the diskless
|
||||||
{
|
* replication was turned off with CONFIG SET, while there were already
|
||||||
|
* slaves in WAIT_BGSAVE_START state. */
|
||||||
|
if (server.rdb_child_pid == -1 && server.aof_child_pid == -1) {
|
||||||
time_t idle, max_idle = 0;
|
time_t idle, max_idle = 0;
|
||||||
int slaves_waiting = 0;
|
int slaves_waiting = 0;
|
||||||
listNode *ln;
|
listNode *ln;
|
||||||
|
Loading…
Reference in New Issue
Block a user