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
87a12a60
Commit
87a12a60
authored
Nov 09, 2015
by
antirez
Browse files
Best effort flush of slave buffers before SHUTDOWN.
parent
b719eedf
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
87a12a60
...
...
@@ -1732,7 +1732,9 @@ void asyncCloseClientOnOutputBufferLimitReached(client *c) {
}
/* Helper function used by freeMemoryIfNeeded() in order to flush slaves
* output buffers without returning control to the event loop. */
* output buffers without returning control to the event loop.
* This is also called by SHUTDOWN for a best-effort attempt to send
* slaves the latest writes. */
void
flushSlavesOutputBuffers
(
void
)
{
listIter
li
;
listNode
*
ln
;
...
...
src/server.c
View file @
87a12a60
...
...
@@ -2490,6 +2490,7 @@ int prepareForShutdown(int flags) {
int
nosave
=
flags
&
SHUTDOWN_NOSAVE
;
serverLog
(
LL_WARNING
,
"User requested shutdown..."
);
/* Kill the saving child if there is a background saving in progress.
We want to avoid race conditions, for instance our saving child may
overwrite the synchronous saving did by SHUTDOWN. */
...
...
@@ -2498,6 +2499,7 @@ int prepareForShutdown(int flags) {
kill
(
server
.
rdb_child_pid
,
SIGUSR1
);
rdbRemoveTempFile
(
server
.
rdb_child_pid
);
}
if
(
server
.
aof_state
!=
AOF_OFF
)
{
/* Kill the AOF saving child as the AOF we already have may be longer
* but contains the full dataset anyway. */
...
...
@@ -2516,6 +2518,8 @@ int prepareForShutdown(int flags) {
serverLog
(
LL_NOTICE
,
"Calling fsync() on the AOF file."
);
aof_fsync
(
server
.
aof_fd
);
}
/* Create a new RDB file before exiting. */
if
((
server
.
saveparamslen
>
0
&&
!
nosave
)
||
save
)
{
serverLog
(
LL_NOTICE
,
"Saving the final RDB snapshot before exiting."
);
/* Snapshotting. Perform a SYNC SAVE and exit */
...
...
@@ -2529,10 +2533,17 @@ int prepareForShutdown(int flags) {
return
C_ERR
;
}
}
/* Remove the pid file if possible and needed. */
if
(
server
.
daemonize
||
server
.
pidfile
)
{
serverLog
(
LL_NOTICE
,
"Removing the pid file."
);
unlink
(
server
.
pidfile
);
}
/* Best effort flush of slave output buffers, so that we hopefully
* send them pending writes. */
flushSlavesOutputBuffers
();
/* Close the listening sockets. Apparently this allows faster restarts. */
closeListeningSockets
(
1
);
serverLog
(
LL_WARNING
,
"%s is now ready to exit, bye bye..."
,
...
...
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