Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1103

CommandResult.getException not detecting "caused by" duplicate key exception

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.13.0, 3.0.0
    • Affects Version/s: 2.11.3
    • Component/s: Error Handling
    • None
    • Environment:
      Java Driver 2.11.3, Mongos + Mongo 2.4.8

      An exception will not get converted to the expected type if a duplicate key error is the underlying error:

      (hosts/ips/oids changed)

       com.mongodb.WriteConcernException: { "serverUsed" : "mongosA/1.2.3.4:27017" ,
       "err" : "error inserting 1 documents to shard shard0001:feeds1/fs1:27017,fs2:27017,fs3:27017,fs4:27017,fs5:27017 at version 37|1||52a65f219cdffac001be7e80 :: caused by :: E11000 duplicate key error index: foursquare.collA.$id  dup key: { : { t: \"s\", o: ObjectId('xyz'), v: ObjectId('abc') } }" ,
      "code" : 16460 , "n" : 0 , "ok" : 1.0}
      

      I believe this happens when the mongos adds the duplicate key error as a "caused by" error.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            slackhappy John Gallagher
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: