mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 09:17:20 +00:00
Add fsync to readSyncBulkPayload(). (#7839)
We should sync temp DB file before renaming as rdb_fsync_range does not use flag `SYNC_FILE_RANGE_WAIT_AFTER`. Refer to `Linux Programmer's Manual`: SYNC_FILE_RANGE_WAIT_AFTER Wait upon write-out of all pages in the range after performing any write.
This commit is contained in:
parent
323029baa6
commit
0d62caab21
@ -1739,6 +1739,17 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
killRDBChild();
|
killRDBChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure the new file (also used for persistence) is fully synced
|
||||||
|
* (not covered by earlier calls to rdb_fsync_range). */
|
||||||
|
if (fsync(server.repl_transfer_fd) == -1) {
|
||||||
|
serverLog(LL_WARNING,
|
||||||
|
"Failed trying to sync the temp DB to disk in "
|
||||||
|
"MASTER <-> REPLICA synchronization: %s",
|
||||||
|
strerror(errno));
|
||||||
|
cancelReplicationHandshake(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Rename rdb like renaming rewrite aof asynchronously. */
|
/* Rename rdb like renaming rewrite aof asynchronously. */
|
||||||
int old_rdb_fd = open(server.rdb_filename,O_RDONLY|O_NONBLOCK);
|
int old_rdb_fd = open(server.rdb_filename,O_RDONLY|O_NONBLOCK);
|
||||||
if (rename(server.repl_transfer_tmpfile,server.rdb_filename) == -1) {
|
if (rename(server.repl_transfer_tmpfile,server.rdb_filename) == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user