shogo82148 / Redis-Fast

fast perl binding for Redis database
https://metacpan.org/release/Redis-Fast
Other
25 stars 21 forks source link

"reconnect disabled inside transaction" is not working sometimes #22

Closed vsespb closed 10 years ago

vsespb commented 10 years ago
use strict;
use warnings;
use Redis::Fast;
my $conn = Redis::Fast->new(
    reconnect     => 20,
    every         => 1000,
);
while(1){
  eval {
    $conn->multi;
    $conn->set("x" => 42);
    $conn->exec;
  1;
  } or do {
    print $@;
  }
}

If I restart Redis server during this script, it should print reconnect disabled inside transaction or watch time to time.

But, it also prints ERR EXEC without MULTI sometimes

reconnect disabled inside transaction or watch at /usr/local/lib/perl/5.14.2/Redis/Fast.pm line 178.
[exec] ERR EXEC without MULTI,  at /usr/local/lib/perl/5.14.2/Redis/Fast.pm line 179.
    Redis::Fast::__ANON__(Redis::Fast=SCALAR(0x2406670)) called at d.pl line 12
    eval {...} called at d.pl line 14

I think that could happen if you copypasted that logic: https://metacpan.org/source/DAMS/Redis-1.976/lib/Redis.pm#L227

first $self->{__inside_transaction} is disabled, and then command is processed. this is a bug.

(same for UNWATCH)