miyagawa / AnyEvent-Redis

Asynchronous Redis client
http://search.cpan.org/dist/AnyEvent-Redis
41 stars 16 forks source link

odd reconnect behavior #18

Closed leedo closed 12 years ago

leedo commented 12 years ago

If a command fails due to a connection error, the client reconnects and queues the original command and callback. The command is retried but fails due to the broken connection, and the command remains in the queue. When the next successful command is issued (say 15 seconds later) the original command and callback are still in the queue and get run.

Using the CondVar style behaves more as I expected, sending to the CondVar callback immediately on connection error.

leedo commented 12 years ago

This patch (2154c734fa49e1daea4cb492e5971ce1e5e6f065) partially fixes the problem. It is included in @chipdude's large error handling pull req, but might be worth an immediate fix since it seems really broken right now.

leedo commented 12 years ago

I dug a little deeper into this and it looks like this is what is happening:

  1. Client connects, executes a some commands
  2. Connection is closed by the server (e.g. server restarts). Note: this doesn't trigger anything on the client (on_error or on eof)
  3. Client tries to execute next command which triggers on_error
  4. Next command successfully reconnects and works

So I think what needs to happen is one reconnect attempt should be made immediately after on_error.

leedo commented 12 years ago

I made a pull req that is working on this: https://github.com/miyagawa/AnyEvent-Redis/pull/19