Consider a compound index with a name:
db.test.ensureIndex( { a: 1, b : 1 }, { unique: true, name : 'index_1' }
A duplicate key error on that index reports this errmsg:
"errmsg" : "insertDocument :: caused by :: 11000 E11000 duplicate key error index: admin.test.$index_1 dup key: { : 1.0, : 2.0 }"
The dup key is a string that looks like JSON but is missing the field names. It would be easier for clients to understand the error message if the dup key contained the field names as well as the values, especially in the case of named indexes where the index name doesn't provide enough of a clue, e.g.
"errmsg" : "insertDocument :: caused by :: 11000 E11000 duplicate key error index: admin.test.$index_1 dup key: { a : 1.0, b : 2.0 }"
I'd also prefer that the index name be rendered without the collection name or the $. Clients know what collection they are using. and the $ is not part of the index name from the clients perspective.
- causes
-
PYTHON-1767 Doctests fails on unexpected keyPattern/keyValue fields in writeErrors
- Closed
- depends on
-
SERVER-37070 All storage engines should show the collection name and the index name in the error message of duplicate keys
- Closed
- is depended on by
-
SERVER-37124 Retry full upsert path when duplicate key exception matches exact query predicate
- Closed
-
SERVER-37532 Retry update on specific duplicate index exception during upsert
- Closed
- is duplicated by
-
NODE-1130 Show full path of duplicate key errors with indexes (Error 11000)
- Closed
-
SERVER-33567 Show full path of duplicate key errors with indexes (Error 11000) (from NODE)
- Closed
- is related to
-
SERVER-33814 Include additional metadata as properties on 11000 error messages
- Closed
-
JAVA-1352 DuplicateKeyException should provide the propertyname which is duplicated
- Closed
- related to
-
SERVER-4637 E11000 (duplicate key error) should return a list of duplicate keys and _ids in insert, bulk insert, and continue_on_error inserts.
- Open
-
SERVER-3069 Add extra fields to getLastError output on duplicate key error
- Closed
-
SERVER-19281 Add index name as a separate field on duplicate key error object
- Closed