-
Notifications
You must be signed in to change notification settings - Fork 96
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
Connection's recv buffer should be emptied before sending new command #52
Comments
Maybe there is another way to solve this problem. Add a |
That sounds reasonable, would you like to make a pr? Or i will try to fix this problem this weekend |
@myrfy001 For now i try to fix this issue by adding attribute to connection to indicate if it is waiting for response, if it is waiting then connection will be disconnected and never put back to available connection list again. The parse response error But i am not sure if this kind of connection should be clean and reused again. |
I think close the connection is the safest way. Think this situation: because of network delay, or because of large responses by bulk execution, the response of the pervious command may arrive after cleaning the buffer. So, close the connection is a safe way to avoid this. Besides, this problem is an edge case so it's seldom happens, so, there won't be a lot of reconnect action that will lower the efficiency. |
That's good, this patch will be tested and merge to master soon. |
@myrfy001 If there are other problems please tell me~ |
@myrfy001 |
It seems working well. |
In some case, if a command was interrupted by outer exceptions(such as timeout), the connection will be released to the pool containing unconsumed data. The unconsumed data will be read by the next command and thus lead to mistake.
The following code can reproduce this situation (it use async_timeout library from aio-libs):
And you will get output like this after running for sometime:
In the code above, a very small timeout value (0.05 second) is set, if you can't reproduce the error, you can try to reduce it to a even smaller one.
The
exists
command will return 0 or 1, and theset
command will get theint
type value returned forexists
command and lead to a error.In my production code, a worker will execute a job with a timeout limit, if the job timeout, it may cause this error.
The text was updated successfully, but these errors were encountered: