Skip to content
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

Occasional exception: org.jredis.connector.ConnectionReset: Connection re-established but last request not processed: in.read returned -1 #57

Closed
subwiz opened this issue Sep 17, 2011 · 10 comments

Comments

@subwiz
Copy link

subwiz commented Sep 17, 2011

This is the trace:

[11-09-16 18:56:25.016] {http://*:8080-18} org.jredis.connector.ConnectionReset: Connection re-established but last request not processed:  in.read returned -1
                                                at org.jredis.ri.alphazero.connection.SyncConnection.serviceRequest(SyncConnection.java:138)
                                                at org.jredis.ri.alphazero.JRedisClient.serviceRequest(JRedisClient.java:151)
                                                at org.jredis.ri.alphazero.JRedisSupport.lrange(JRedisSupport.java:1218)
                                                at in.fileit.fileitin.OpPost.getKeyPosts(OpPost.java:360)
                                                at in.fileit.fileitin.OpPost.getPosts(OpPost.java:408)
                                                at in.fileit.fileitin.ServletIndex.doGet(ServletIndex.java:26)
                                                at javax.servlet.http.HttpServlet.service(HttpServlet.java:119)
                                                at javax.servlet.http.HttpServlet.service(HttpServlet.java:96)
                                                at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:109)
                                                at in.fileit.fileitin.FilterDataSource.doFilter(FilterDataSource.java:58)
                                                at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:89)
                                                at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:156)
                                                at com.caucho.server.webapp.AccessLogFilterChain.doFilter(AccessLogFilterChain.java:95)
                                                at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:287)
                                                at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:811)
                                                at com.caucho.network.listen.TcpSocketLink.dispatchRequest(TcpSocketLink.java:1186)
                                                at com.caucho.network.listen.TcpSocketLink.handleRequest(TcpSocketLink.java:1148)
                                                at com.caucho.network.listen.TcpSocketLink.handleRequestsImpl(TcpSocketLink.java:1132)
                                                at com.caucho.network.listen.TcpSocketLink.handleRequests(TcpSocketLink.java:1055)
                                                at com.caucho.network.listen.TcpSocketLink.handleAcceptTask(TcpSocketLink.java:903)
                                                at com.caucho.network.listen.AcceptTask.doTask(AcceptTask.java:74)
                                                at com.caucho.network.listen.ConnectionTask.runThread(ConnectionTask.java:97)
                                                at com.caucho.network.listen.ConnectionTask.run(ConnectionTask.java:80)
                                                at com.caucho.network.listen.AcceptTask.run(AcceptTask.java:59)
                                                at com.caucho.env.thread.ResinThread.runTasks(ResinThread.java:164)
                                                at com.caucho.env.thread.ResinThread.run(ResinThread.java:130)

This is happening on random basis. I am using the latest jredis from trunk ( 2c58286 ) and using Redis 2.2.12.

@alphazero
Copy link
Owner

That's due to a connection timeout. Java does not raise an error on a dropped connection on send and it's only on the read end that you get a -1 returned (with semantics as defined in the javadocs e.g. "connection reset"). What is the timeout value in redis conf?

@subwiz
Copy link
Author

subwiz commented Sep 21, 2011

It is set at 300 seconds in redis.conf.

This could also be due to the way I implemented Connection management---using ThreadLocal. So I will verify if there are any connections open in my side for more than 300 seconds.

Thanks for the pointer.

@alphazero
Copy link
Owner

NP; happy to help. I assumed you were pooling connections; can you confirm?

@subwiz
Copy link
Author

subwiz commented Sep 21, 2011

I was believing that I have to manually pool connections..., so I implemented my logic based on a Servlet Filter which creates a new Redis connection, and throughout this particular request flow, this connection is used. Is there a better approach for pooling connections?

@subwiz subwiz closed this as completed Sep 21, 2011
@subwiz subwiz reopened this Sep 21, 2011
@alphazero
Copy link
Owner

hmm. If you have a connection per request, then why would it even be idle for > 300s ??

@subwiz
Copy link
Author

subwiz commented Sep 21, 2011

I have to run some test if my implementation of ThreadLocal is holding connections open. So do you know of any OpenSource connection pool library for JRedis?

@subwiz subwiz closed this as completed Sep 21, 2011
@subwiz subwiz reopened this Sep 21, 2011
@subwiz
Copy link
Author

subwiz commented Sep 22, 2011

I added few logs to my application and see that it is indeed timeout problem. Now I have pointer to work on this issue independently. I am closing this issue because this is not a JRedis bug.

Thanks a lot for the pointer.

@subwiz subwiz closed this as completed Sep 22, 2011
@alphazero alphazero reopened this Sep 22, 2011
@alphazero
Copy link
Owner

Reopening as documentation issue.

@alphazero
Copy link
Owner

Closing this. The javadoc for the exception states explicitly this is "typically due to timeout on Redis side".

@subwiz
Copy link
Author

subwiz commented Sep 23, 2011

Can this also be added as part of Exception message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants