diff options
author | menwen <menwenjun@gmail.com> | 2022-04-20 14:54:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-20 09:54:55 +0300 |
commit | 046654a70e604413c3a91a97e621351c64b0e6ad (patch) | |
tree | cb6c6a1bf167647ccc7bd50a00bd6eb193257abf /src/replication.c | |
parent | 5075e74366c99033886bce13fcd504a2c57fa180 (diff) | |
download | redis-046654a70e604413c3a91a97e621351c64b0e6ad.tar.gz |
Stop RDB child before flushing and parsing the RDB in Diskless replication too (#10602)
We should stop RDB child in advance before flushing to reduce COW in diskless replication too.
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/replication.c')
-rw-r--r-- | src/replication.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/replication.c b/src/replication.c index e3ee728da..2a0404f87 100644 --- a/src/replication.c +++ b/src/replication.c @@ -1975,6 +1975,20 @@ void readSyncBulkPayload(connection *conn) { /* We need to stop any AOF rewriting child before flushing and parsing * the RDB, otherwise we'll create a copy-on-write disaster. */ if (server.aof_state != AOF_OFF) stopAppendOnly(); + /* Also try to stop save RDB child before flushing and parsing the RDB: + * 1. Ensure background save doesn't overwrite synced data after being loaded. + * 2. Avoid copy-on-write disaster. */ + if (server.child_type == CHILD_TYPE_RDB) { + if (!use_diskless_load) { + serverLog(LL_NOTICE, + "Replica is about to load the RDB file received from the " + "master, but there is a pending RDB child running. " + "Killing process %ld and removing its temp file to avoid " + "any race", + (long) server.child_pid); + } + killRDBChild(); + } if (use_diskless_load && server.repl_diskless_load == REPL_DISKLESS_LOAD_SWAPDB) { /* Initialize empty tempDb dictionaries. */ @@ -2106,16 +2120,6 @@ void readSyncBulkPayload(connection *conn) { connNonBlock(conn); connRecvTimeout(conn,0); } else { - /* Ensure background save doesn't overwrite synced data */ - if (server.child_type == CHILD_TYPE_RDB) { - serverLog(LL_NOTICE, - "Replica is about to load the RDB file received from the " - "master, but there is a pending RDB child running. " - "Killing process %ld and removing its temp file to avoid " - "any race", - (long) server.child_pid); - killRDBChild(); - } /* Make sure the new file (also used for persistence) is fully synced * (not covered by earlier calls to rdb_fsync_range). */ |