Describe the bug
Redis 6 doesn't shut down if its directory doesn't exist.
To reproduce
~ $ cat redis.conf
dir /Users/dcantrell/temp
unixsocket /Users/dcantrell/redis.sock
port 0
~ $ mkdir temp
~ $ redis-server redis.conf
27790:C 22 Feb 2022 16:07:40.574 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27790:C 22 Feb 2022 16:07:40.574 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=27790, just started
...
At this point Redis is running just fine. Now in another terminal ...
~ $ rmdir temp
~ $ kill -TERM 27790 # this is the PID redis-server spat out above
~ $
But back in the original terminal redis-server says:
27790:signal-handler (1645546400) Received SIGTERM scheduling shutdown...
27790:M 22 Feb 2022 16:13:20.793 # User requested shutdown...
27790:M 22 Feb 2022 16:13:20.793 * Saving the final RDB snapshot before exiting.
27790:M 22 Feb 2022 16:13:20.793 # Failed opening the RDB file dump.rdb (in server root dir unknown) for saving: No such file or directory
27790:M 22 Feb 2022 16:13:20.793 # Error trying to save the DB, can't exit.
27790:M 22 Feb 2022 16:13:20.793 # SIGTERM received but errors trying to shut down the server, check the logs for more information
Expected behavior
redis-server should terminate while still loudly complaining.
Additional information
Redis 5 behaves as I expect - it terminates on SIGTERM even if the directory doesn't exist.
Comment From: oranagra
that's by design, shutdown I'll cause data loss, You can use SHUTDOWN NOSAVE, or clear the save config before sending SIGTERM
Comment From: DrHyde
Ah, that makes sense. Thanks.
Comment From: oranagra
Regarding redis 5, IIRC there was a bug and the default save config wasn't applied in some cases, so that's probably why it didn't refuse to shutdown.