This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
forked from evilkost/brukva
-
Notifications
You must be signed in to change notification settings - Fork 162
Client can't be shared on concurrent conditions #83
Comments
I'm getting similar errors using
It seems that once I try to send more than 1 concurrent request from a client to tornado it somehow messes up the things and tornaod doesn't seem to be able to query that data properly from that point on. Sending a single request to tornado works fine. |
Having the same as well. |
workaround soluction: https://github.com/leporo/tornado-redis#connection-pool-support |
@gitchs I used connection-poll but have the same question. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When tornado-redis used as a shared client, it will sometimes crash in
process_data
Test code
Test it with
apache-bench
ab -c2 -n2 http://localhost:9000/
the crash log:
Environment:
tornado==4.0.2 tornado-redis==2.4.18
I think the problem is, when parsing the redis response, especially Bulk Strings,
execute_command
splits the reading operation into two separate tasks, one for the response type and length (eg. "$5\r\n"), and a second task to get the rest data. But tornado's IOLoop may take task-switch between two reading tasks, under this condition the shared connection may be read twice both for the response type, and the second task may consume wrong response type.Generally, a
get
command will execute like this:write command (W) -> get response type and length -> (RC) -> get rest response data (RD)
in concurrent condition, 2 concurrent requests for example, a connection may be accessed in this order
W1 -> W2 -> RC1 -> RC2 (crash, bad response type) ...
The text was updated successfully, but these errors were encountered: