2

When I insert documents into Mongo-DB using morphia, it always occur com.mongodb.MongoException$Network: Write operation to server exceptions, maybe interval of one minute The follow is the stack info:

com.mongodb.MongoException$Network: Write operation to server
    at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:153)
    at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:115)
    at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:327)
    at com.mongodb.DBCollection.update(DBCollection.java:178)
    at com.mongodb.DBCollection.save(DBCollection.java:818)
    at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:882)
    at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:949)
    at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:934)
    at com.yeahmobi.datasystem.conversion.datarepository.mongodb.MongoTransmappingRepository.insert(MongoTransmappingRepository.java:36)
    at com.yeahmobi.datasystem.conversion.datarepository.merge.MergeTransmappingRepository.insert(MergeTransmappingRepository.java:24)
    at com.yeahmobi.datasystem.conversion.threads.JumpInserter.saveJumpLog(JumpInserter.java:134)
    at com.yeahmobi.datasystem.conversion.threads.JumpInserter.run(JumpInserter.java:163)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    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.go(DBPort.java:106)
    at com.mongodb.DBPort.findOne(DBPort.java:162)
    at com.mongodb.DBPort.runCommand(DBPort.java:170)
    at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:100)
    at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:142)

Is there anyone meet the same issues? Any sugguestion is appreciated.

Thanks

2
  • What are your versions of Morphia & MongoDB? Do you have a firewall or load balancer in front of your MongoDB instance? If the interval is consistently about 1 minute, it sounds like there is some sort of timeout happening. Commented Jan 24, 2014 at 14:39
  • Thanks for you comments, my morphia version is 0.104 and the MongoDB is 2.4. I hava checked the network and server load, they are all not heigh. The LBS was used, but now it has been changed to use the direct connection with IP. And there are about 12% insert will failed Commented Jan 25, 2014 at 1:03

1 Answer 1

2

This is unusual and should not happen often during normal operation.

Try to debug from networking/OS perspective, check the following:

  • Is the connectivity between application and Mongo reliable? What's the packet drop rate and latency?
  • Is there enough network bandwidth between application and Mongo?
  • Has there been any software/hardware trouble on the application/Mongo server?
  • Was the server on high load when it happens?
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your anwsers, the notwork/Server looks like ok. But there also are 12% insert failed. The mongo client options are: MongoClientOptions options = MongoClientOptions.builder() .autoConnectRetry(true) .maxAutoConnectRetryTime(10) .socketTimeout(2000) .socketKeepAlive(true).build()
The problem has been solved. When I add two datanode, the issue disappeared

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.