Perl Cache::Memcached 1.24 dead host bug..

Danny dmarkham at eventful.com
Wed Jul 25 06:18:02 UTC 2007


So if you have a server down  and a client starts up in v1.24 it  
keeps trying to use that host over and over
(not just after to ~ 20sec timeout)


After digging in it seems that in-order for _dead_sock to work it has  
to be an entry in %sock_map with the socket your tying to mark dead..
But we don't add it to the  %sock_map until after you get a valid  
connection with no errors.


So I "fixed" it by making sure what it needed was in the sock_map before
calling _dead_sock

sub sock_to_host {
.
.
.

             unless (_connect_sock($sock,$sin,$timeout)) {
                 my $cb = $self ? $self->{cb_connect_fail} : undef;
                 $cb->($ip) if $cb;
     ==>>   $sock_map{$sock} = $host;    ## add it so we can delete  
it in _dead_sock
                 return _dead_sock($sock, undef, 20 + int(rand(10)));
             }

And right below this for the unix domain failure case also..
Worked like a charm..

Ideas? Thoughts?

Thanks,
-Dan Markham
Eventful, Inc.
  


More information about the memcached mailing list