Intermittent Mongo DB error on Writes

91 views
Skip to first unread message

Rajesh Dighe

unread,
Nov 18, 2010, 6:42:48 PM11/18/10
to mongodb-user
I am using Mongo version 1.6.3 in Master-Slave Configuration (one
master, one slave) with Mongo Java driver 2.3

The below error is seen on master intermittently. How do I avoid this?

I am seeing one of the write operation would give below error and then
consequent writes will work. Its very random.


Nov 18, 2010 12:29:58 PM com.mongodb.DBTCPConnector$MyPort error
SEVERE: MyPort.error called
java.net.SocketException: Connection reset
at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
at java.net.SocketOutputStream.write(SocketOutputStream.java:
136)
at org.bson.io.PoolOutputBuffer.pipe(PoolOutputBuffer.java:
113)
at com.mongodb.OutMessage.pipe(OutMessage.java:157)
at com.mongodb.DBPort.go(DBPort.java:86)
at com.mongodb.DBPort.say(DBPort.java:60)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:151)
at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:
289)
at com.mongodb.DBCollection.update(DBCollection.java:112)
at com.mongodb.DBCollection.update(DBCollection.java:119)
at
com.sling.sacextras.rest.restlet.MemberFavoritesRestlet.handle(MemberFavoritesRestlet.java:
204)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:135)
at org.restlet.Router.handle(Router.java:445)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:135)
at org.restlet.Filter.doHandle(Filter.java:105)
at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:
89)
at org.restlet.Filter.handle(Filter.java:135)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:135)
at
com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:
98)
at org.restlet.Application.handle(Application.java:294)
at
com.slingmedia.rest.restlet.app.RestApplication.handle(RestApplication.java:
65)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:135)
at org.restlet.Router.handle(Router.java:445)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:135)
at org.restlet.Router.handle(Router.java:445)
at org.restlet.Filter.doHandle(Filter.java:105)
at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:
89)
at org.restlet.Filter.handle(Filter.java:135)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:135)
at
com.noelios.restlet.component.ComponentHelper.handle(ComponentHelper.java:
120)
at org.restlet.Component.handle(Component.java:231)
at org.restlet.Server.handle(Server.java:282)
at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:
100)
at
com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:
94)
at
com.noelios.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:
398)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
874)
at org.apache.coyote.http11.Http11BaseProtocol
$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:
665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:
528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:
81)
at org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
- 163319032 [http-8586-Processor2] ERROR XXXRestlet -
com.mongodb.MongoException$Network: can't say something

Alvin Richards

unread,
Nov 18, 2010, 7:58:35 PM11/18/10
to mongodb-user
Rajesh,

Could you paste your Java connection code.

Thanks

-Alvin

Eliot Horowitz

unread,
Nov 19, 2010, 5:30:42 AM11/19/10
to mongod...@googlegroups.com
Generally connection reset is caused by some network layer issue.
Can you check connectivity from app server to mongod.
Any errors on mongod?
Is there a router in between that could be closing connections?

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Nat

unread,
Nov 19, 2010, 7:34:30 AM11/19/10
to mongodb-user
could it be that the message is too big? I saw a similar problem with
C# driver version 0.5 where it can send too large message to server
and the server resets the connection?
> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio nFilterChain.java:
> > 269)
> >        at
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC hain.java:
> > 188)
> >        at
> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j ava:
> > 213)
> >        at
> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j ava:
> > 174)
> >        at
> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
> > 127)
> >        at
> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
> > 117)
> >        at
> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav a:
> > 108)
> >        at
> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
> > 151)
> >        at
> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
> > 874)
> >        at org.apache.coyote.http11.Http11BaseProtocol
> > $Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:
> > 665)
> >        at
> > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.ja va:
> > 528)
> >        at
> > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerW orkerThread.java:

Eliot Horowitz

unread,
Nov 19, 2010, 9:42:20 AM11/19/10
to mongod...@googlegroups.com
No. A too large message should be impossible. If you have a reproducible case we can look

Paulo Gabriel Poiati

unread,
Nov 19, 2010, 9:46:45 AM11/19/10
to mongod...@googlegroups.com
Rajesh, I'm having this problem with java-driver 2.3 too, but it runs fine with 2.2. Can you change to 2.2 and see what happens ?

ty

[]'s
Paulo Poiati

blog.paulopoiati.com

Rajesh Dighe (Sling Media)

unread,
Nov 19, 2010, 8:38:24 PM11/19/10
to mongodb-user
Hi Alvin

Below is sample code giving error intermittently. The problem is seen
with Java Mongo Driver 2.2 and 2.3.
Note I am using db.requestStart and db.requestDone


//Connect to the database and collection
Mongo m = new Mongo();
DB db = m.getDB(“xyz”);
db.requestStart();
DBCollection coll = db.getCollection(“uuu”);

//Package the first part of the query
BasicDBObject query = new BasicDBObject();
query.put("user_id", userid);
BasicDBObject query1 = new BasicDBObject();
query1.put("abc", abc);
query1.put("def", def);
query1.put("ghi", ghi);
query.put("array", new BasicDBObject("$elemMatch",
query1));

//Package the second part of the query
BasicDBObject update = new BasicDBObject();
BasicDBObject update1 = new BasicDBObject();
update1.put("recent.$.abc", abc);
update1.put("recent.$.date", new
Date().getTime());
update1.put("recent.$.def", def);
update.put("$set", update1);
update.put("$inc", new BasicDBObject("recent.
$.count", 1));

//Execute the query
WriteResult r = coll.update(query, update); -->
(Exception is thrown here)
db.requestDone();

Thanks
Rajesh


On Nov 18, 4:58 pm, Alvin Richards <al...@10gen.com> wrote:
> Rajesh,
>
> Could you paste your Java connection code.
>
> Thanks
>
> -Alvin
>

Rajesh Dighe (Sling Media)

unread,
Dec 7, 2010, 2:18:20 PM12/7/10
to mongodb-user
Hi Alvin

Doing some more research the error seems to be coming out because of
Connection Socket timeout - possibly keep alive timeout.

Can anyone advise on the usage of MongoOptions to increase the
timeout.

Sample Java drive code appreciated

Rajesh



On Nov 19, 6:42 am, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> No. A too large message should be impossible. If you have a reproducible case we can look
>
> On Nov 19, 2010, at 7:34 AM, Nat <nat.lu...@gmail.com> wrote:
>
> > could it be that the message is too big? I saw a similar problem with
> > C# driver version 0.5 where it can send too large message to server
> > and the server resets the connection?
>
> > On Nov 19, 6:30 pm, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> >> Generally connection reset is caused by some network layer issue.
> >> Can you check connectivity from app server to mongod.
> >> Any errors on mongod?
> >> Is there a router in between that could be closing connections?
>

Rajesh Dighe (Sling Media)

unread,
Dec 7, 2010, 2:22:05 PM12/7/10
to mongodb-user
..Also Alvin. How do we set the network keep-alive from withing the
Java Driver?

Thanks
Rajesh




On Dec 7, 11:18 am, "Rajesh Dighe (Sling Media)"

Alvin Richards

unread,
Dec 7, 2010, 2:42:34 PM12/7/10
to mongodb-user
API documentation for the Java driver is here

http://api.mongodb.org/java/2.3/index.html

If you take a look at MongoOptions, you can set connection and socket
timeouts

http://api.mongodb.org/java/2.3/com/mongodb/MongoOptions.html

These are passed into the Mongo object on connection, for eaxmple

MongoOptions mo = new MongoOptions();
mo.autoConnectRetry = true;

Mongo mongo = new Mongo( "localhost:27017" , mo );

-Alvin


On Dec 7, 2:22 pm, "Rajesh Dighe (Sling Media)"
Reply all
Reply to author
Forward
0 new messages