Weird issue with redis-cli BGREWRITEAOF in cron

398 views
Skip to first unread message

Julien Genestoux

unread,
Sep 7, 2010, 11:31:29 PM9/7/10
to redi...@googlegroups.com
Heya,

So, we updagred both our servers and client libes to the last stable release :)
So far so good... but today, I noticed that our BGREWRITEAOF cron job wasn't working.

After a few minutes of investigation, I found out that the last version to date of the client was generating an error : "ERR wrong number of arguments for 'bgrewriteaof' command", which is odd because it used to work fine, and it still does work perfectly fine if I type this command direcly from the shell :/

The cronfile looks like this :
# crontab -l
*/3 * * * *  redis-cli BGREWRITEAOF

Anyone has a clue?


Cheers!

Julien Genestoux

unread,
Sep 7, 2010, 11:46:15 PM9/7/10
to redi...@googlegroups.com
Also, I actually found a way :
*/3 * * * * echo "BGREWRITEAOF" | redis-cli

But it's probably not as "clean" as the simple redis-cli BGREWRITEAOF!

Salvatore Sanfilippo

unread,
Sep 8, 2010, 6:18:48 AM9/8/10
to redi...@googlegroups.com
Hello Julien,

this is a problem specifically related to running redis cli inside the cron job.
Pieter hacked about this issue recently, so I'll lave the reply to him ;)

Thanks for reporting.

Cheers,
Salvatore

> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to
> redis-db+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/redis-db?hl=en.
>

--
Salvatore 'antirez' Sanfilippo
http://invece.org

"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele

Julien Genestoux

unread,
Sep 8, 2010, 1:17:16 PM9/8/10
to redi...@googlegroups.com
Cool :)

Joran Greef

unread,
Sep 9, 2010, 5:42:06 AM9/9/10
to Redis DB
Would it be possible to add a conf option to have Redis run
BGREWRITEAOF automatically at intervals?

Salvatore Sanfilippo

unread,
Sep 9, 2010, 6:16:34 AM9/9/10
to redi...@googlegroups.com
On Thu, Sep 9, 2010 at 11:42 AM, Joran Greef <joran...@gmail.com> wrote:
> Would it be possible to add a conf option to have Redis run
> BGREWRITEAOF automatically at intervals?

Yes, this makes sense and should be done indeed...

Cheers,
Salvatore

Joran Greef

unread,
Sep 9, 2010, 6:52:51 AM9/9/10
to Redis DB
Thanks Salvatore

On Sep 9, 12:16 pm, Salvatore Sanfilippo <anti...@gmail.com> wrote:
> On Thu, Sep 9, 2010 at 11:42 AM, Joran Greef <jorangr...@gmail.com> wrote:
> > Would it be possible to add a conf option to have Redis run
> > BGREWRITEAOF automatically at intervals?
>
> Yes, this makes sense and should be done indeed...
>
> Cheers,
> Salvatore
>
> > --
> > You received this message because you are subscribed to the Google Groups "Redis DB" group.
> > To post to this group, send email to redi...@googlegroups.com.
> > To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/redis-db?hl=en.
>
> --
> Salvatore 'antirez' Sanfilippohttp://invece.org

Julien

unread,
Oct 12, 2010, 3:06:24 AM10/12/10
to Redis DB
So, it looks like after updating to the last version of the server,
even `echo "BGREWRITEAOF" | redis-cli` doesn't work anymore.. which is
very very very annoying.
Any suggestion on how to achieve this, while you guys are implementing
this timing feature in redis ?

Thanks.

Julien

unread,
Oct 20, 2010, 12:54:42 PM10/20/10
to Redis DB
What's the status of this?
We had a server dying once again because of this defect. it's very
very very annoying.

I underdtand you cannot release a fix right now, but what do you
suggest? What do people use to BGREWRITEAOF run regularly?


Thanks,

Tim Haines

unread,
Oct 20, 2010, 10:10:48 PM10/20/10
to redi...@googlegroups.com
I use a scheduled resque job to kick it off..

Pieter Noordhuis

unread,
Oct 21, 2010, 3:44:20 AM10/21/10
to redi...@googlegroups.com
Hi Julien,

There were numerous issues with redis-cli and reading from STDIN. The
initial idea to make it as unix-intuitive as possible (e.g. reading
from a pipe when there is a pipe). Unfortunately, this appeared to
have unexpected consequences when run from scripts (or cron for that
matter), where redis-cli would block waiting for data from a pipe,
when there was none. To circumvent this, we've (re-)added a flag to
redis-cli that tells it to read the last argument from STDIN. Now,
adding the -x option will read from STDIN instead of it being
automatically (thus sometimes falsely) detected.

Example:
2.0.0: "echo /proc/cpuinfo | redis-cli set cpuinfo" would detect the
pipe when run from a tty, but otherwise it would block.
2.0.1: "echo /proc/cpuinfo | redis-cli -x set cpuinfo" will never
block because you must supply the -x flag.

So, earlier, you had to "echo BGREWRITEAOF | redis-cli", because it
was trying to read from STDIN in the cron. Now, reading from STDIN
requires an extra flag, so you can simply issue "redis-cli
BGREWRITEAOF".

Cheers,
Pieter

Salvatore Sanfilippo

unread,
Oct 21, 2010, 4:45:30 AM10/21/10
to redi...@googlegroups.com
On Thu, Oct 21, 2010 at 9:44 AM, Pieter Noordhuis <pcnoo...@gmail.com> wrote:

> So, earlier, you had to "echo BGREWRITEAOF | redis-cli", because it
> was trying to read from STDIN in the cron. Now, reading from STDIN
> requires an extra flag, so you can simply issue "redis-cli
> BGREWRITEAOF".

Thank you Pieter.
This was my idea as well. Julien can you please confirm that you were
using not the latest version?

Cheers,
Salvatore

--
Salvatore 'antirez' Sanfilippo

Julien Genestoux

unread,
Oct 22, 2010, 1:05:38 PM10/22/10
to redi...@googlegroups.com
Hi, sorry for the late response... I didn't know about the -x option, but we do use redis-cli which comes with redis 2.0.2.
I'm deploying the code with it now. Let's see what happens.
Thanks,


Reply all
Reply to author
Forward
0 new messages