Ben
Ben

Reputation: 41

Redis Blocking Save

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?

Upvotes: 4

Views: 4176

Answers (3)

antirez
antirez

Reputation: 18514

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.

Upvotes: 8

psyho
psyho

Reputation: 7212

Redis#save does just that. What version of Redis and redis gem are you using?

Upvotes: 0

Andy Lindeman
Andy Lindeman

Reputation: 12165

SAVE is a synchronous save; BGSAVE is the asynchronous one.

Why do you think SAVE is running in the background?

Upvotes: 0

Related Questions