-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
hiredis hangs on redisBufferRead #263
Comments
It is blocked on a system call. Looks like a kernel issue to me. Have you tried replicating the issue on machines with newer kernel versions? |
I believe the client has sent the message which has not reached or not handled by redis server. As the client is in the block mode, it waits indefintely for the response from the redis server. Even netstat output indicates SendQ of the tcp socket having 43 bytes ( in our case ). This behaviour is observed only between hiredis & redis communication. We have couple of program which uses tcp & http and its works fine. |
@saravanan-elangovan Are you connecting with a timeout? This just looks like it's blocking on the socket which doesn't mean there is any actual issue with hiredis, per se. Now, it's possible that there is some weird edge case where hiredis fails to send the complete command, but we use hiredis to send billions of commands to Redis over several hours and/or days and don't see this behavior. The only obvious difference is that we're running 64 bit hiredis. |
I met the same issue in 2012 and 2013. And in these days I met them again. Maybe it's due to the old lib, but why this issue is still keeping open status. enviroment:
thread stacks:[Switching to thread 3 (Thread 0x7fdbee57b700 (LWP 7795))]#0 0x000000348c40e75d in read () fro m /lib64/libpthread.so.0 |
No one investigated this in more detail yet, but as per the comments above this might be an issue with the network or the Redis contacting and not a bug in hiredis itself. |
[rafael@tesla001 softwares]$ netstat |
So all connections to the Redis server are already half-closed, which might indicate a completely different problem. |
sorry bad boy, I run netstat again, it looks I deleted some established connections last time. actually there are active connections. paste them all: [rafael@tesla001 softwares]$ netstat |
your netstat output shows there is no none-zero sendq. btw. you can use redisSetTimeout() to set read/write timeout value. |
@echoma Thanks. Actually I used redisSetTimeout() and I found the reason finally. I used multi-threads with the api, but it doesn't support. |
So this can be closed? |
@badboy Yes, I have solved the problem by move all api calls in the same thread. But @saravanan-elangovan opened this issue, I am not sure he met the same situation like me. |
shoutrain commented on 4 May 2015 Actually I used redisSetTimeout() and I found the reason finally. I used multi-threads with the api, but it doesn't support. Question:hiredis doesn't support multi-threads? where i can see it? I used multi-threads also! |
@abigbigbird Can see what? |
Oh,I saw the note ! thanks I use hiredis in my project,It works fine in most of the time,but there are several times ,it hangs。 ## the gdb core stack as below:: os:Red Hat Enterprise Linux Server release 6.4 (Santiago) |
@abigbigbird Is this the same as #442? If so, please re-open there. This issue here seems to be another problem. |
oh,sorry,i saw it core at the same code。my fault! |
I am running into a similar backtrace on gdb. I am using hiredis for mainly get/set queries. It works fine most of the times but once in a while it hangs on RedisBufferRead(). |
The same issue here:
The server is not redis, but similar as redis: https://github.com/antirez/disque EDIT: I use a single instance for |
same issue here if i run it in a multi- threads |
sometimes we are even unaware of threading usage, like being in an callback routine, why dont we introduce a mutex inside redisCommand? I believe there are many products in the market shipped with this bug and the authors have not noticed |
Making hiredis thread safe would require a lot more than just adding a mutex to The solution, I think, is to handle synchronization in each individual application in the best way for that application. There are also thread-safe wrappers to hiredis available but I have not used any of them personally. |
Closing this old issue, since it's not clear there is actually a bug being described. |
We use hiredis to connect to redis server in block mode. Our application runs in RHEL 4 32 bit. It works fine and after some time while trying to do an operation, it hangs. On analysis, found it got hanged in the redisBufferRead. This application act like a switch which gets the data from TCP Socket and store the same in the Redis database for recoverability.
On netstat output, We found the SendQ of the our client has non-zero value which indicates that request has not reached redis server. This behaviour happens with INCR & INCRBY mostly.
We opened a redis-client and did the same operation and it works fine.
gdb output
#0 0x008787a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x001de69b in __read_nocancel () from /lib/tls/libpthread.so.0
#2 0x08073a42 in redisBufferRead (c=0x89c2fb8) at hiredis.c:1142
#3 0x08073c59 in redisGetReply (c=0x89c2fb8, reply=0x590dcbc) at hiredis.c:1228
#4 0x08073e99 in redisvCommand (c=0x89c2fb8, format=0x8077f40 "INCRBY %s %ld", ap=0x590dcf8 "t\021\225\b\001") at hiredis.c:1332
#5 0x08073ed2 in redisCommand (c=0x89c2fb8, format=0x8077f40 "INCRBY %s %ld") at hiredis.c:1349
The text was updated successfully, but these errors were encountered: