Possible problem with redis package in repository
Posted: Wed Jul 17, 2013 2:14 am
I was deploying redis on CentOS on a few of servers for my organization, and I was coming up with a monit script to make sure redis stays alive and shuts down cleanly in case of issues.
I realized that the init script given with the redis package might have a small bug.
Redis has a SHUTDOWN command which does a clean shut down after saving all data to disk. This can take a little time if there is a lot of data. This command can be initiated by passing a TERM signal to the process. However, in the redis init script, no signal is specified in the killproc command in the stop() section. If no signal is specified to killproc, it initially sends a TERM and waits for 100000 microseconds, and then sends a KILL if its still running. I think this can lead to data loss if the redis takes more than .1 of a second to save data to disk (which it will if it has any significant amount of data).
I think the fix is passing the "-TERM" argument to killproc in the init script.
Refer:
[http://redis.io/commands/shutdown](http://redis.io/commands/shutdown)
[http://redis.io/topics/signals](http://redis.io/topics/signals)
I realized that the init script given with the redis package might have a small bug.
Redis has a SHUTDOWN command which does a clean shut down after saving all data to disk. This can take a little time if there is a lot of data. This command can be initiated by passing a TERM signal to the process. However, in the redis init script, no signal is specified in the killproc command in the stop() section. If no signal is specified to killproc, it initially sends a TERM and waits for 100000 microseconds, and then sends a KILL if its still running. I think this can lead to data loss if the redis takes more than .1 of a second to save data to disk (which it will if it has any significant amount of data).
I think the fix is passing the "-TERM" argument to killproc in the init script.
Refer:
[http://redis.io/commands/shutdown](http://redis.io/commands/shutdown)
[http://redis.io/topics/signals](http://redis.io/topics/signals)