Skip to content

Redis on Windows - Save RDB but Not Able to Persist

September 23rd, 2017 - ITTutorial(1 min)

TL;DR: My windows service wasn’t installed properly. Change the config file to point the DB to an accessible directory and reinstall the service.

When trying to build a perioduc Celery task, I got the following error with Redis on Windows (running as a windows service):

redis.exceptions.ResponseError: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

This is quite unfortunate because the error doesn’t show at the very beginning, but only after about 5 mins on my computer.

The error obviously occurs because Redis can’t save the database snapshot. This can be tested with the following steps:

  1. Restart the service

  2. Execute the info command with redis-cli

    redis-cli info |grep bg

    which will produce an initial result:

    rdb_bgsave_in_progress:0
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:1
    rdb_current_bgsave_time_sec:-1
    aof_last_bgrewrite_status:ok
  3. Trigger a save

    redis-cli bgsave
    # Background saving started
  4. Show the command again

    redis-cli info | grep bg
    rdb_bgsave_in_progress:0
    rdb_last_bgsave_status:err
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    aof_last_bgrewrite_status:ok

you can see the rdb_last_bgsave_status:err status, which means the DB could not have been saved

To fix this, go to your REDIS installation (mine is on C:\ProgramData\chocolatey\lib\redis-64 because I’ve installed it via chocolatey) and:

  1. Uninstall the windows service

    ./redis-server --service-uninstall
  2. Edit the database directory to somewhere accessible (in redis.windows-service.conf)

    # ...
    dir C:/Users/[myuser]/tmp
    # ...

    while replacing [myuser] with your relevant user and creating the C:/Users/[myuser]/tmp directory

  3. Install the service (again)

    ./redis-server --service-install redis.windows-service.conf --loglevel verbose
  4. Start the service

    ./redis-server --service-start

Now, the service should work. If not, then look in the Event Viewer, Applications and Services Logs > redis for more details.

HTH,

Share on
Reddit
Linked in
Whatsapp

A little experiment: