Closed leonliao closed 1 year ago
Treating this type of expiration as error, the Redis connection will be cleaned up as well, causing too many reconnects
Even if we can distinguish these two kinds of errors, we have to close the connection when the connection is timeout.
Because when a connection is timed-out, we've no idea whether the request has been sent to Redis. If we don't close the connection, but reuse it, when we send another command to Redis, we might get reply from a former command:
In a word, we have to close the connection, when it's timed-out. In order to avoid closing the connection frequently, in your case, you need to set a larger socket_timeout.
Regards
Since there's no update, I'll close this issue.
Regards
It is possible commands expire in the libuv queue, before sending to network. That could be caused by
For reason 1, it is NOT possible to read responses of other commands which have been sent to Redis? I suggest that for this type of expiration, it is OK to not close the connection. Of course, the reason of expiration must be distinguishable.
First of all, I’m not sure if libuv support distinguishing these two kinds of timeout. Secondly, even if it has such support, currently, hiredis doesn’t have an interface to do that. Since redis-plus-plus is based on hiredis, we can not support the feature you proposed.
So sorry for that, and I will keep an eye on this problem. If you have any new ideas on it, feel free to let me know.
Regards
发件人: leonliao @.> 发送时间: Tuesday, January 31, 2023 10:12:54 AM 收件人: sewenew/redis-plus-plus @.> 抄送: sewenew @.>; State change @.> 主题: Re: [sewenew/redis-plus-plus] [BUG] Improper error when hiredis libuv expiration happens (Issue #444)
It is possible commands expire in the libuv queue, before sending to network. That could be caused by
For reason 1, it is NOT possible to read responses of other commands which have been sent to Redis? I suggest that for this type of expiration, it is OK to not close the connection. Of course, the reason of expiration must be distinguishable.
― Reply to this email directly, view it on GitHubhttps://github.com/sewenew/redis-plus-plus/issues/444#issuecomment-1409641708, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWWTAPDEFZULMNXF7OZZH3WVBYKNANCNFSM6AAAAAATYXZKFM. You are receiving this because you modified the open/close state.Message ID: @.***>
OK. This is not a critical issue. Let's keep it as it is now.
Describe the bug I use redis++ 1.3.7 with hiredis 1.1.0 to connect to a Redis Cluster. Hiredis 1.1.0 added libuv expiration support by fixing this issue https://github.com/redis/hiredis/issues/1015. When libuv expiration happens, "connection has been closed" error was thrown in ClusterEvent
From the stack trace, if a command event in libuv queue expires before sending to network, the callback
redisAsyncHandleTimeout
will be invoked, andnull
reply is passed. So, anullptr
in reply in_cluster_reply_callback
doesn't necessary meanconnection has been closed
.Treating this type of expiration as error, the Redis connection will be cleaned up as well, causing too many reconnects. And that has been observed by wireshark network captures.
To Reproduce
Expected behavior
host/port in redisAsyncContext.c.tcp or unix_sock.path
for better diagnosis to know which Redis node is down.Environment:
Additional context NA