djveremix / redis

Automatically exported from code.google.com/p/redis
0 stars 0 forks source link

BLPOP within a transaction can crash #285

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I was trying to do something like pipelining queue reads like a "real MQ" might 
do:

(echo multi; echo blpop foo 0; echo blpop foo 0; echo exec) | ./redis-cli& 
(sleep 1; echo lpush foo bar; echo lpush foo bar) | ./redis-cli

Both 2.0.0-RC2 and git master crash.

Original issue reported on code.google.com by dgl...@gmail.com on 16 Jul 2010 at 5:24

Attachments:

GoogleCodeExporter commented 8 years ago
Accepted... thank you, working on this issue right now.

Cheers,
Salvatore

Original comment by anti...@gmail.com on 30 Aug 2010 at 2:04

GoogleCodeExporter commented 8 years ago
Ok, I checked the issue. For sure there is a bug, as BLPOP should just work if 
the list is not empty when inside a MULTI/BULK, and should never block. That is 
in other words, BLPOP should act as LPOP inside a MULTI/EXEC block.

Instead you can use pipelining with BLPOP, there is nothing wrong with it... 
just pipelining != multi/exec. Example:

In one terminal I run:
{{{

Connected to localhost.
Escape character is '^]'.
BLPOP foo 0
BLPOP foo 0
*2
$3
foo
$3
bar
*2
$3
foo
$3
bar
}}}

While in another one I was doing:

{{{
(sleep 1; echo lpush foo bar; echo lpush foo bar) | ./redis-cli
}}}

As you can see this works well.

Now what I'm doing is to turn BLPOP into LPOP (the same fro BRPOP of course) 
when inside a MULTI/EXEC block.

Original comment by anti...@gmail.com on 30 Aug 2010 at 2:18

GoogleCodeExporter commented 8 years ago
Fixed, thanks for reporting! Tests added.

Original comment by anti...@gmail.com on 30 Aug 2010 at 2:39