Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2bc8db9c
Commit
2bc8db9c
authored
Dec 31, 2019
by
ShooterIT
Committed by
ShooterIT
Dec 31, 2019
Browse files
Rename rdb asynchronously
parent
6e4f70b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/replication.c
View file @
2bc8db9c
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "server.h"
#include "server.h"
#include "cluster.h"
#include "cluster.h"
#include "bio.h"
#include <sys/time.h>
#include <sys/time.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -1616,14 +1617,20 @@ void readSyncBulkPayload(connection *conn) {
...
@@ -1616,14 +1617,20 @@ void readSyncBulkPayload(connection *conn) {
killRDBChild
();
killRDBChild
();
}
}
/* Rename rdb like renaming rewrite aof asynchronously. */
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
)
{
serverLog
(
LL_WARNING
,
serverLog
(
LL_WARNING
,
"Failed trying to rename the temp DB into %s in "
"Failed trying to rename the temp DB into %s in "
"MASTER <-> REPLICA synchronization: %s"
,
"MASTER <-> REPLICA synchronization: %s"
,
server
.
rdb_filename
,
strerror
(
errno
));
server
.
rdb_filename
,
strerror
(
errno
));
cancelReplicationHandshake
();
cancelReplicationHandshake
();
if
(
old_rdb_fd
!=
-
1
)
close
(
old_rdb_fd
);
return
;
return
;
}
}
/* Close old rdb asynchronously. */
if
(
old_rdb_fd
!=
-
1
)
bioCreateBackgroundJob
(
BIO_CLOSE_FILE
,(
void
*
)(
long
)
old_rdb_fd
,
NULL
,
NULL
);
if
(
rdbLoad
(
server
.
rdb_filename
,
&
rsi
,
RDBFLAGS_REPLICATION
)
!=
C_OK
)
{
if
(
rdbLoad
(
server
.
rdb_filename
,
&
rsi
,
RDBFLAGS_REPLICATION
)
!=
C_OK
)
{
serverLog
(
LL_WARNING
,
serverLog
(
LL_WARNING
,
"Failed trying to load the MASTER synchronization "
"Failed trying to load the MASTER synchronization "
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment