aredis icon indicating copy to clipboard operation
aredis copied to clipboard

Connection not disconnected when cancelled

Open mjwestcott opened this issue 5 years ago • 1 comments

Checklist

  • Python 3.7 and 3.8
  • Using hiredis
  • Using uvloop
  • Exists on master

Steps to reproduce

I found unexpected errors in 'flaky' CI integration tests (e.g. here)

The problem is that the response here is for example b'OK' or b'QUEUED', which has the wrong type and compares False against the length of the commands.

I believe this is caused by state from a previous use of a connection that is not properly disconnected or cleaned up when a cancellation happens.

I think the problem is here, which disconnects and cleans up on some types of exception, but not asyncio.CancelledError which can be raised in the exec above.

Expected behavior

Connection is disconnected/cleaned up when a cancellation happens, so that when a connection is reused there is no old state.

Actual behavior

Connection is not disconnected/cleaned up when a cancellation happens, so when a connection is reused, we receive the old response.

mjwestcott avatar Aug 26 '20 15:08 mjwestcott

Sorry for the lack of small reproducible example, it's quite a deep bug.

I've tested https://github.com/NoneGG/aredis/pull/172 locally against my project's integration test suite and it seems to solve the problem.

mjwestcott avatar Aug 26 '20 15:08 mjwestcott