-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 2.11.0
-
Component/s: Error Handling
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
hoffrocket reports:
We have some error handling code that depends on catching a DuplicateKey exception. We started getting a WriteConcernException instead after upgrading to the 2.11.3 version of the driver from 2.9.3
The problem is that mongoS doesn't return a "code" in the response (at least in the version which we're using: 2.2.3). Previous versions of the driver checked for a string in the "err", but that was removed in 2.11.x.
Do newer versions of mongoS propagate the "code"?
Here's a pull request: https://github.com/mongodb/mongo-java-driver/pull/153
Here's an example of a response:
{
"err": "E11000 duplicate key error index: foursquare.coll.$_id_ dup key: { : 1 }",
"errObjects": [
{
"code": 11000,
"connectionId": 1514529,
"err": "E11000 duplicate key error index: foursquare.coll.$_id_ dup key: { : 1 }",
"lastOp": {
"$inc": 9,
"$ts": 1384877384
},
"n": 0,
"ok": 1.0
},
{
"code": 11000,
"connectionId": 1866741,
"err": "E11000 duplicate key error index: foursquare.coll.$_id_ dup key: { : 2 }",
"lastOp": {
"$inc": 0,
"$ts": 0
},
"n": 0,
"ok": 1.0
}
],
"errs": [
"E11000 duplicate key error index: foursquare.coll.$_id_ dup key: { : 1 }",
"E11000 duplicate key error index: foursquare.coll.$_id_ dup key: { : 2 }"
],
"n": 0,
"ok": 1.0,
"serverUsed": "/127.0.0.1:27017",
"shardRawGLE": {
"shard0/a:27017,b:27017": {
"code": 11000,
"connectionId": 1514529,
"err": "E11000 duplicate key error index: foursquare.coll.$_id_ dup key: { : 1 }",
"lastOp": {
"$inc": 9,
"$ts": 1384877384
},
"n": 0,
"ok": 1.0
},
"shard1/c:27017,d:27017": {
"code": 11000,
"connectionId": 1866741,
"err": "E11000 duplicate key error index: foursquare.coll.$_id_ dup key: { : 2 }",
"lastOp": {
"$inc": 0,
"$ts": 0
},
"n": 0,
"ok": 1.0
}
},
"shards": [
"shard0/a:27017,b:27017",
"shard1/c:27017,d:27017"
]
}
- duplicates
-
JAVA-1081 CommandResult.getException not detecting duplicate key errors reported in errObjects field
-
- Closed
-