com.mongodb.MongoException: error counting : { "errmsg" : "exception: type not supported for appendMinElementForType" , "code" : 10061 , "ok" : 0.0}

JIRA | auto | 3 years ago
  1. Speed up your debug routine!

    Automated exception search integrated into your IDE

  2. 0

    I've been trying to an application against a replica pair of mongodb 1.4.3 servers with driver version 2.0 (also occurs on 1.4). I've noticed an issue when servers switch master/slave roles that the driver is not transitioning and instead the error message filters up through the application. Here is a sample stack trace: com.mongodb.MongoException: error counting : { "" : "not master" , "ok" : 0.0} at com.mongodb.DBCollection.getCount(DBCollection.java:524) at com.mongodb.DBCollection.getCount(DBCollection.java:492) This error will occur if the master of the pair is taken down then brought back up without the application being aware of it. At that point, the current server in the driver would be pointing to the slave server. So, the next request from the driver would get "not master" error. After some investigation, I noticed that the problem appears to be in the way the error is caught. The driver expects errors to be in the format { "$err" : "....." }, however, in this case what I am seeing is { "errmsg" : "not master" } which doesn't get caught by Response.java as an error (so all the logic that is supposed to take place does not get triggered). I've locally made changes to also take "errmsg" as a valid error and then the switch between master/slave works. I've attached the two modified files for driver 2.0. I'm not certain why this error isn't coming up as "$err" - which would seem reasonable.

    JIRA | 6 years ago | Razvan Loghin
    com.mongodb.MongoException: error counting : { "" : "not master" , "ok" : 0.0}

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. com.mongodb.MongoException

      error counting : { "errmsg" : "exception: type not supported for appendMinElementForType" , "code" : 10061 , "ok" : 0.0}

      at com.mongodb.DBCollection.getCount()
    2. MongoDB Java Driver
      DBCursor.size
      1. com.mongodb.DBCollection.getCount(DBCollection.java:771)
      2. com.mongodb.DBCursor.size(DBCursor.java:632)
      2 frames
    3. com.gowonder.test
      Testclass.main
      1. com.gowonder.test.classes.Testclass.main(Testclass.java:76)
      1 frame