-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Shell
-
None
-
Query Optimization
-
(copied to CRM)
Say we have two documents with two fields in a collection (testing), with a compound unique index:
use test
db.testing.insert({ a: 1, b: 1 })
db.testing.insert({ a: 1, b: 2 })
db.testing.createIndex({ a: 1, b: 1 }, { unique: true })
The error message generated by a call to findAndModify that violates the unique index is as follows:
test> db.testing.findAndModify({ query: { a: 1,b: 1 }, update: { a: 1,b: 2 } }) 2018-03-12T21:46:46.427-0400 E QUERY [thread1] Error: findAndModifyFailed failed: { "operationTime": Timestamp(1520905600, 1), "ok": 0, "errmsg": "E11000 duplicate key error collection: test.testing index: a_1_b_1 dup key: { : 1.0, : 2.0 }", "code": 11000, "codeName": "DuplicateKey", "$clusterTime": { "clusterTime": Timestamp(1520905600, 1), "signature": { "hash": BinData(0, "eiANq76RZ704EWnDJSY3orlIWxM="), "keyId": NumberLong("6532150305184808961") } } } : _getErrorWithCode@src/mongo/shell/utils.js:25:13 DBCollection.prototype.findAndModify@src/mongo/shell/collection.js:724:1 @(shell):1:1
In the above error message, codeName is specified. However in an insert or update operation, the codeName field is not specified:
test> db.testing.insert({a:1,b:1}) E11000 duplicate key error collection: test.testing index: a_1_b_1 dup key: { : 1.0, : 1.0 } WriteResult({ "nInserted": 0, "writeError": { "code": 11000, "errmsg": "E11000 duplicate key error collection: test.testing index: a_1_b_1 dup key: { : 1.0, : 1.0 }" } })
These error messages should be made consistent across all methods in the shell.
- is related to
-
SERVER-36755 writeErrors codeName is set in sharded cluster topology only
- Backlog