[JAVA-1302] MongoDB Cursor timeout Created: 02/Jul/14  Updated: 11/Sep/19  Resolved: 31/Jul/14

Status: Closed
Project: Java Driver
Component/s: API, Query Operations
Affects Version/s: 2.12.2
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Daniel Heitepriem Assignee: Unassigned
Resolution: Done Votes: 0
Labels: cursor, exception, java, sharded-cluster, timeout
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB Sharded Cluster with two replica sets



 Description   

I'm using an sharded-cluster with a java application. After a specifid time (10 minutes or more) I got the following exception:

com.mongodb.MongoException$Network: Read operation to server cs-mongo-mongo-west-t/10.4.0.110:3306 failed on database mdb
        at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:253)
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
        at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288)
        at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:273)
        at com.mongodb.DBCursor._check(DBCursor.java:368)
        at com.mongodb.DBCursor._hasNext(DBCursor.java:459)
        at com.mongodb.DBCursor._fill(DBCursor.java:518)
        at com.mongodb.DBCursor.toArray(DBCursor.java:553)
        at com.mongodb.DBCursor.toArray(DBCursor.java:542)
        at com.pribas.messagesdb.impl.GetMessagesDBHandlerImpl.handleRequest(GetMessagesDBHandlerImpl.java:86)
        at com.pribas.messagesdb.impl.MessagesDBHandlerImpl.handleRequest(MessagesDBHandlerImpl.java:37)
        at com.pribas.messagesdb.service.MessageServlet.processRequest(MessageServlet.java:161)
        at com.pribas.messagesdb.service.MessageServlet.doPost(MessageServlet.java:86)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Zeitlimit f\303\274r Verbindung \303\274berschritten
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.io.BufferedInputStream.fill(Unknown Source)
        at java.io.BufferedInputStream.read1(Unknown Source)
        at java.io.BufferedInputStream.read(Unknown Source)
        at org.bson.io.Bits.readFully(Bits.java:46)
        at org.bson.io.Bits.readFully(Bits.java:33)
        at org.bson.io.Bits.readFully(Bits.java:28)
        at com.mongodb.Response.<init>(Response.java:40)
        at com.mongodb.DBPort.go(DBPort.java:142)
        at com.mongodb.DBPort.call(DBPort.java:92)
        at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:244)
        ... 30 more

Is there a way to disable this timeout of the cursor within the sharded-cluster or within the config-file?

Thank you very much,
Daniel



 Comments   
Comment by Jeffrey Yemin [ 31/Jul/14 ]

Thanks for responding with the outcome. I'm going to close this ticket.

Comment by Daniel Heitepriem [ 05/Jul/14 ]

Hi Jeff,

just as a result. It was indeed a network problem. After implementing a heartbeat the problem was solved.

Thank you for your help.
Regards,
Daniel

Comment by Daniel Heitepriem [ 03/Jul/14 ]

Hi Jeff,
my application does not change this value. I will have a look at my network and will tell when I found a solution.

Regards,
Daniel

Comment by Jeffrey Yemin [ 02/Jul/14 ]

This isn't a cursor timeout, it's a socket exception. Using Google Translate, it looks like the message is something like "Exceeded connection timeout". The default for the driver is to never time out on socket reads (see com.mongodb.MongoClientOptions#getSocketTimeout). Is your application by any chance changing that default? If not, it's possible that a timeout is being triggered lower down in the stack, and you'll have to do some analysis of your network to find the root cause.

Generated at Thu Feb 08 08:54:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.