[JAVA-1103] CommandResult.getException not detecting "caused by" duplicate key exception Created: 31/Jan/14  Updated: 30/Jan/15  Resolved: 17/Oct/14

Status: Closed
Project: Java Driver
Component/s: Error Handling
Affects Version/s: 2.11.3
Fix Version/s: 2.13.0, 3.0.0

Type: Improvement Priority: Minor - P4
Reporter: John Gallagher Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Java Driver 2.11.3, Mongos + Mongo 2.4.8


Issue Links:
Depends
depends on SERVER-11493 Use a specific error code for duplica... Closed
Related
is related to PYTHON-592 OperationFailure is raised instead of... Closed
is related to JAVA-1081 CommandResult.getException not detect... Closed

 Description   

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.



 Comments   
Comment by Githook User [ 30/Jan/15 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Support sharded DuplicateKey exceptions

JAVA-1103
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/8b55e446b63e3662094e772471c17c49ae9d1cc3

Comment by Githook User [ 17/Oct/14 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Support sharded DuplicateKey exceptions

JAVA-1103
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/8b55e446b63e3662094e772471c17c49ae9d1cc3

Comment by Githook User [ 17/Oct/14 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Support sharded DuplicateKey exceptions

JAVA-1103
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/cff488446ee77edd50cad0b6edc1f204c4145b21

Comment by Ross Lawley [ 09/Jul/14 ]

Thanks hoffrocket for the Pull request - we will review in due course

Comment by Jon Hoffman [ 08/Jul/14 ]

This is still a problem in 2.12.2 on mongoS 2.4.9. Created a pull request to fix. https://github.com/mongodb/mongo-java-driver/pull/225

You can duplicate the problem using the test project here: https://github.com/hoffrocket/mongo-dup-key

Comment by John Gallagher [ 31/Jan/14 ]

Related: JAVA-1081

Generated at Thu Feb 08 08:53:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.