com.mongodb.MongoException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • a client using the java driver encounters exceptions when reading from a server that gets restarted gracefully, although another node is up and available for reads. I use a topology of 2 nodes, with one being set as a fixed primary for my tests. on the client side I use read mode primaryPreferred. during the test, I constantly query a collection while repeatdly restarting the primary using the windows service. the expectation is that a read never fails because: 1) the primary is gracefully restarted and 2) the secondary is always up and running. during the course of running the test, I get exceptions on the client side from time to time. so far I identified these 2: {code} java.lang.NullPointerException at com.mongodb.DBTCPConnector$MyPort.error(DBTCPConnector.java:470) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:281) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:290) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:275) at com.mongodb.DBCollection.findOne(DBCollection.java:727) at com.mongodb.DBCollection.findOne(DBCollection.java:669) at com.lodh.arte.test.robustmongo.ReproducerPrimaryPreferredSystemTest.readSecondary(ReproducerPrimaryPreferredSystemTest.java:87) {code} {code} com.mongodb.MongoException: not talking to master and retries used up at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:304) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:306) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:306) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:290) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:275) at com.mongodb.DBCollection.findOne(DBCollection.java:727) at com.mongodb.DBCollection.findOne(DBCollection.java:669) at com.lodh.arte.test.robustmongo.ReproducerPrimaryPreferredSystemTest.readSecondary(ReproducerPrimaryPreferredSystemTest.java:87) {code}
    via by Vincent Sevel,
  • [mongodb-user] db error [not master]
    via by Zsombor,
  • Error using $elemMatch
    via GitHub by ubiquitousthey
    ,
  • Does the Java Driver support $slice operator?
    via by Stuart King,
  • Depending on where the null characters appear and how many of them there are, you get different errors. Here's one reproducible case using Java: {code} DBCollection c = m.getDB("test").getCollection("CS4355"); String s = URLDecoder.decode("/students?%2500%16%00%00%00%02hello%00%06%00%00%00world%00%00=%2500", "UTF-8"); DBObject obj = new BasicDBObject("embedded", new BasicDBObject(s, 1)); c.insert(obj, WriteConcern.SAFE); DBObject objOut = c.findOne(obj); System.out.println(objOut); {code} The insert returns normally, but the call to findOne throws an exception: {noformat} Exception in thread "main" com.mongodb.MongoException: BSONElement: bad type 101 at com.mongodb.MongoException.parse(MongoException.java:82) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:293) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:274) at com.mongodb.DBCollection.findOne(DBCollection.java:710) at com.mongodb.DBCollection.findOne(DBCollection.java:652) at CS4355.main(CS4355.java:39) {noformat} and validate fails as well: {noformat} Mon Sep 10 20:56:55 [conn2] runQuery called test.$cmd { validate: "CS4355", full: true } Mon Sep 10 20:56:55 [conn2] run command test.$cmd { validate: "CS4355", full: true } Mon Sep 10 20:56:55 [conn2] CMD: validate test.CS4355 Mon Sep 10 20:56:55 [conn2] Assertion: 13655:BSONElement: bad type 101 0x10007fd6c 0x1000082ad 0x1000162a1 0x10001632e 0x1004ab99f 0x1004adce6 0x10048c3a4 0x10048cd76 0x10045457b 0x10045600a 0x1003a6b61 0x1003a7b02 0x1005a678f 0x1001387ad 0x1005b2af9 0x7fff86d6d782 0x7fff86d5a1c1 0 mongod 0x000000010007fd6c _ZN5mongo11msgassertedEiPKc + 396 1 mongod 0x00000001000082ad _ZNK5mongo11BSONElement4sizeEi + 461 2 mongod 0x00000001000162a1 _ZNK5mongo7BSONObj5validEv + 177 3 mongod 0x000000010001632e _ZNK5mongo7BSONObj5validEv + 318 4 mongod 0x00000001004ab99f _ZN5mongo11ValidateCmd10validateNSEPKcPNS_16NamespaceDetailsERKNS_7BSONObjERNS_14BSONObjBuilderE + 6543 5 mongod 0x00000001004adce6 _ZN5mongo11ValidateCmd3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb + 518 6 mongod 0x000000010048c3a4 _ZN5mongo11execCommandEPNS_7CommandERNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb + 2692 7 mongod 0x000000010048cd76 _ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi + 694 8 mongod 0x000000010045457b _ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi + 59 9 mongod 0x000000010045600a _ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 5818 10 mongod 0x00000001003a6b61 _ZN5mongoL13receivedQueryERNS_6ClientERNS_10DbResponseERNS_7MessageE + 337 11 mongod 0x00000001003a7b02 _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 1458 12 mongod 0x00000001005a678f _ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE + 271 13 mongod 0x00000001001387ad _ZN5mongo3pms9threadRunEPNS_13MessagingPortE + 605 14 mongod 0x00000001005b2af9 thread_proxy + 137 15 libsystem_c.dylib 0x00007fff86d6d782 _pthread_start + 327 16 libsystem_c.dylib 0x00007fff86d5a1c1 thread_start + 13 Mon Sep 10 20:56:55 [conn2] Invalid bson detected in test.CS4355 with _id: ObjectId('504e8c4e57862e8db678a9a2') {noformat}
    via by Jeff Yemin,
    • com.mongodb.MongoException: not talking to master and retries used up at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:304) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:306) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:306) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:290) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:275) at com.mongodb.DBCollection.findOne(DBCollection.java:727) at com.mongodb.DBCollection.findOne(DBCollection.java:669) at com.lodh.arte.test.robustmongo.ReproducerPrimaryPreferredSystemTest.readSecondary(ReproducerPrimaryPreferredSystemTest.java:87)
    No Bugmate found.