-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Another race condition in health checks and pubsub #1740
Comments
Thanks, I'll take a look when I can - but it will probably only be next week as I have some fires to put out first. |
Using this issue I found #1737 have a different error: After I fixed it and added a subscription at the end of the script, I was able to reproduce the issue you mentioned. The bug in 1737 can be reproduced with:
|
…m the execute_command method only in the first command execution.
Version: redis-py 4.0.2, Redis 6.2.6. Also reproduces with #1733 or #1737 applied.
Platform: Python 3.8, Ubuntu 20.04
Description: This is somewhat similar to #1720, but different. If
get_message
is called between issuing an UNSUBSCRIBE command that removes that last subscription, and getting the unsubscribe message back, andparse_response
decides it needs to do a health check, then the reply to the health check is mis-interpreted. This is because redis responds differently to PING depending on whether there are active subscriptions or not, andparse_response
only recognises the one form.aioredis has the same bug, and the fix (recognise both possible responses) would probably work for redis-py too.
Code to reproduce the issue (it's a race condition so might not work every time, but it's been reliable for me). Depends on a redis server on localhost:
It subscribes, then waits 2 seconds (to make the health check interval kick in), then races to call
get_message
andunsubscribe
.Output:
The last line is the problem. It's caused by trying to treat a byte string (b"redis-py-health-check") as a list and selecting elements from it (114, 101, 100 are the ASCII codes for 'r', 'e', 'd').
The text was updated successfully, but these errors were encountered: