mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 17:40:50 +00:00
Best effort flush of slave buffers before SHUTDOWN.
This commit is contained in:
parent
b719eedfc6
commit
87a12a6085
@ -1732,7 +1732,9 @@ void asyncCloseClientOnOutputBufferLimitReached(client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Helper function used by freeMemoryIfNeeded() in order to flush slaves
|
/* 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) {
|
void flushSlavesOutputBuffers(void) {
|
||||||
listIter li;
|
listIter li;
|
||||||
listNode *ln;
|
listNode *ln;
|
||||||
|
11
src/server.c
11
src/server.c
@ -2490,6 +2490,7 @@ int prepareForShutdown(int flags) {
|
|||||||
int nosave = flags & SHUTDOWN_NOSAVE;
|
int nosave = flags & SHUTDOWN_NOSAVE;
|
||||||
|
|
||||||
serverLog(LL_WARNING,"User requested shutdown...");
|
serverLog(LL_WARNING,"User requested shutdown...");
|
||||||
|
|
||||||
/* Kill the saving child if there is a background saving in progress.
|
/* Kill the saving child if there is a background saving in progress.
|
||||||
We want to avoid race conditions, for instance our saving child may
|
We want to avoid race conditions, for instance our saving child may
|
||||||
overwrite the synchronous saving did by SHUTDOWN. */
|
overwrite the synchronous saving did by SHUTDOWN. */
|
||||||
@ -2498,6 +2499,7 @@ int prepareForShutdown(int flags) {
|
|||||||
kill(server.rdb_child_pid,SIGUSR1);
|
kill(server.rdb_child_pid,SIGUSR1);
|
||||||
rdbRemoveTempFile(server.rdb_child_pid);
|
rdbRemoveTempFile(server.rdb_child_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.aof_state != AOF_OFF) {
|
if (server.aof_state != AOF_OFF) {
|
||||||
/* Kill the AOF saving child as the AOF we already have may be longer
|
/* Kill the AOF saving child as the AOF we already have may be longer
|
||||||
* but contains the full dataset anyway. */
|
* but contains the full dataset anyway. */
|
||||||
@ -2516,6 +2518,8 @@ int prepareForShutdown(int flags) {
|
|||||||
serverLog(LL_NOTICE,"Calling fsync() on the AOF file.");
|
serverLog(LL_NOTICE,"Calling fsync() on the AOF file.");
|
||||||
aof_fsync(server.aof_fd);
|
aof_fsync(server.aof_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create a new RDB file before exiting. */
|
||||||
if ((server.saveparamslen > 0 && !nosave) || save) {
|
if ((server.saveparamslen > 0 && !nosave) || save) {
|
||||||
serverLog(LL_NOTICE,"Saving the final RDB snapshot before exiting.");
|
serverLog(LL_NOTICE,"Saving the final RDB snapshot before exiting.");
|
||||||
/* Snapshotting. Perform a SYNC SAVE and exit */
|
/* Snapshotting. Perform a SYNC SAVE and exit */
|
||||||
@ -2529,10 +2533,17 @@ int prepareForShutdown(int flags) {
|
|||||||
return C_ERR;
|
return C_ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove the pid file if possible and needed. */
|
||||||
if (server.daemonize || server.pidfile) {
|
if (server.daemonize || server.pidfile) {
|
||||||
serverLog(LL_NOTICE,"Removing the pid file.");
|
serverLog(LL_NOTICE,"Removing the pid file.");
|
||||||
unlink(server.pidfile);
|
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. */
|
/* Close the listening sockets. Apparently this allows faster restarts. */
|
||||||
closeListeningSockets(1);
|
closeListeningSockets(1);
|
||||||
serverLog(LL_WARNING,"%s is now ready to exit, bye bye...",
|
serverLog(LL_WARNING,"%s is now ready to exit, bye bye...",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user