Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis Blocking Save

Tags:

ruby

redis

How can I force Redis to do a blocking save? I am using the Ruby Redis gem, but I believe this question is not specific to that library. It seems like SAVE and a BGSAVE commands seem to flutter away doing stuff in the background, causing "-ERR background save in progress" errors on subsequent calls.

Hopefully this would be a boring, synchronous call that blocks all other Redis commands until the save over "dump.rdb" is finished. And hopefully this will not require actually shutting down the server, mucking around with "/etc/init.d/redis-server". Presumably I should be polling with the LASTSAVE command?

like image 901
Ben Avatar asked Feb 26 '23 07:02

Ben


1 Answers

if you call SAVE but you get an error about a background save in progress, this means that there is also a BGSAVE in progress, becuase one of this is true:

1) Somebody called BGSAVE 2) Redis is configured to save from time to time (the default).

So your SAVE fails since there is already a save in progress. You can check if there is a background in progress, and when it is completed, checking the INFO output.

like image 59
antirez Avatar answered Mar 08 '23 10:03

antirez