[SERVER-11493] Use a specific error code for duplicate key error when sharded Created: 30/Oct/13 Updated: 10/Dec/14 Resolved: 11/Dec/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Bernie Hackett | Assignee: | Randolph Tan |
| Resolution: | Duplicate | Votes: | 7 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||
| Description |
|
Most drivers raise a specific DuplicateKeyError exception for "duplicate key" errors. They do this by checking error returns for specific error codes. mongos raises error code 16460 for a range of insert errors, including duplicate key error. That error should be handled separately, using a specific code (ErrorCodes::DuplicateKey is appropriate). The sharding code in question: https://github.com/mongodb/mongo/blob/master/src/mongo/s/strategy_shard.cpp#L704-L726 |
| Comments |
| Comment by Michael Korbakov [ 18/Dec/13 ] | |||||||||||||||||||||||||||||||||||
|
Can we expect to see this fix back ported to 2.4 branch? | |||||||||||||||||||||||||||||||||||
| Comment by Randolph Tan [ 11/Dec/13 ] | |||||||||||||||||||||||||||||||||||
|
This is already fixed in master: using write commands:
using old style writes:
| |||||||||||||||||||||||||||||||||||
| Comment by Eliot Horowitz (Inactive) [ 10/Dec/13 ] | |||||||||||||||||||||||||||||||||||
|
Should make sure this is correct in write commands. | |||||||||||||||||||||||||||||||||||
| Comment by Eliot Horowitz (Inactive) [ 10/Dec/13 ] | |||||||||||||||||||||||||||||||||||
|
Michael, I don't think so. | |||||||||||||||||||||||||||||||||||
| Comment by Michael Korbakov [ 10/Dec/13 ] | |||||||||||||||||||||||||||||||||||
|
Is it possible that this error renders continue_on_error option of insert useless? Our testing shows that inserting bulk of documents with some of them violating unique index fails to insert non-violating ones. It only started with upgrade to MongoDB 2.4, everything worked fine with 2.2. |