[SERVER-3069] Add extra fields to getLastError output on duplicate key error Created: 09/May/11  Updated: 06/Dec/22  Resolved: 11/Oct/18

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Mathias Stearn Assignee: Backlog - Storage Execution Team
Resolution: Duplicate Votes: 21
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-19281 Add index name as a separate field on... Closed
Related
is related to SERVER-14801 duplicate key error should report fie... Closed
Assigned Teams:
Storage Execution
Participants:

 Description   

Should at least have field name and duplicated value.

See http://stackoverflow.com/questions/5939720/better-ways-to-handle-mongodb-exceptions



 Comments   
Comment by Eli Skeggs [ 17/Oct/13 ]

We have a number of collections with multiple unique indexes that could be violated. It looks like our only option to differentiate which index was violated in the event of an E11000 is to parse the error message, which works but is a hacky solution to what I would imagine is not an uncommon problem. This feature would be very much appreciated. Thanks!

Comment by Aristarkh Zagorodnikov [ 11/Aug/11 ]

Voted on this, but thought I should write something too.
The message for error 11000 currently at least be parsed to extract the index name. The message for error 11001 doesn't contain even that information.
Having index name along with the name of the field and it's value as separate fields in a result document for both errors would be very welcome for run-time and post-mortem (log-based) debugging.

Generated at Thu Feb 08 03:01:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.