aredis icon indicating copy to clipboard operation
aredis copied to clipboard

redis command get executed twice

Open sileht opened this issue 5 years ago • 2 comments

Checklist

  • Python version: 3.7
  • Using hiredis
  • Using uvloop
  • Does issue exists against the master branch of aredis? yes

Steps to reproduce

The symptom was a redis pipeline executed twice successfully in row while in run pipeline.execute() only one time.

My pipeline was executed here : https://github.com/NoneGG/aredis/blob/aecfafd06aa1a08d81538cd9ed2e11fc119bfb16/aredis/pipeline.py#L285

And another time here: https://github.com/NoneGG/aredis/blob/aecfafd06aa1a08d81538cd9ed2e11fc119bfb16/aredis/pipeline.py#L300

So I digged to understand why this ConnectionError occurs while this is not really a connection issue since the two send commands have succeed from redis point of view.

The root cause was that I mess up to run the redis command into the correct loop.

Asyncio raises a RuntimeError to inform developer in such case, but this one was hidden by aredis code here:

https://github.com/NoneGG/aredis/blob/master/aredis/connection.py#L313-L315

And RuntimeError was recasted to a ConnectionError, the working redis connection (but attached to another loop) get close, a new one was create bind to the current running loop, and the command is resent.

Expected behavior

aredis should not convert all exceptions into ConnectionError, it should catch only Exception related to connection issues.

Actual behavior

aredis convert any exception into ConnectionError and hide some programatic error occuring in caller code.

sileht avatar May 21 '20 22:05 sileht

Sounds reasonable, i will check and fix it soon, thanks a lot~

NoneGG avatar May 23 '20 17:05 NoneGG

@NoneGG I've also run into this exact problem

mjwestcott avatar Aug 26 '20 01:08 mjwestcott