*Redis Signals Handling

This document provides information about how Redis reacts to the reception of different POSIX signals such as SIGTERM, SIGSEGV and so forth.

The information contained in this document is only applicable to Redis version 2.6 or greater.

*Handling of SIGTERM

The SIGTERM signals tells Redis to shutdown gracefully. When this signal is received the server does not actually exits as a result, but it schedules a shutdown very similar to the one performed when the SHUTDOWN command is called. The scheduled shutdown starts ASAP, specifically as long as the current command in execution terminates (if any), with a possible additional delay of 0.1 seconds or less.

In case the server is blocked by a Lua script that is taking too much time, if the script is killable with SCRIPT KILL the scheduled shutdown will be executed just after the script is killed, or if terminates spontaneously.

The Shutdown performed in this condition includes the following actions:

In case the RDB file can't be saved, the shutdown fails, and the server continues to run in order to ensure no data loss. Since Redis 2.6.11 no further attempt to shut down will be made unless a new SIGTERM will be received or the SHUTDOWN command issued.


The following follow signals are handled as a Redis crash:

Once one of these signals is trapped, Redis aborts any current operation and performs the following actions:

*What happens when a child process gets killed

When the child performing the Append Only File rewrite gets killed by a signal, Redis handles this as an error and discards the (probably partial or corrupted) AOF file. The rewrite will be re-triggered again later.

When the child performing an RDB save is killed Redis will handle the condition as a more severe error, because while the effect of a lack of AOF file rewrite is a the AOF file enlargement, the effect of failed RDB file creation is lack of durability.

As a result of the child producing the RDB file being killed by a signal, or when the child exits with an error (non zero exit code), Redis enters a special error condition where no further write command is accepted.

This error condition is cleared only once it will be possible to create an RDB file with success.

*Killing the RDB file without triggering an error condition

However sometimes the user may want to kill the RDB saving child without generating an error. Since Redis version 2.6.10 this can be done using the special signal SIGUSR1 that is handled in a special way: it kills the child process as any other signal, but the parent process will not detect this as a critical error and will continue to serve write requests as usually.