[SERVER-46810] Broken E11000 duplicate key error when unique index contains collation Created: 11/Mar/20 Updated: 29/Oct/23 Resolved: 15/Apr/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying, Usability |
| Affects Version/s: | None |
| Fix Version/s: | 4.2.7, 4.4.0-rc4, 4.7.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dmitry Lukyanov (Inactive) | Assignee: | David Storch |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | collation, qexec-team | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||
| Backport Requested: |
v4.4, v4.2
|
||||||||||||||||||||
| Sprint: | Query 2020-04-20 | ||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Description |
|
The E11000 duplicate key exception contains wrong details which sometimes lead to the exception on the driver since we cannot parse it. Consider the following queries:
Then, try to add two the same documents one by one:
It looks like this ticket is related to https://jira.mongodb.org/browse/SERVER-26050 |
| Comments |
| Comment by Githook User [ 07/May/20 ] |
|
Author: {'name': 'David Storch', 'email': 'david.storch@mongodb.com', 'username': 'dstorch'}Message: Also changes the error message to include the index's (cherry picked from commit 9dbaf78c605a576db8b15895c32aedc3e07d7ec8) |
| Comment by Githook User [ 06/May/20 ] |
|
Author: {'name': 'David Storch', 'email': 'david.storch@mongodb.com', 'username': 'dstorch'}Message: Also changes the error message to include the index's (cherry picked from commit 9ca0c11865bba19999932a57069daed84a4577ca) |
| Comment by David Storch [ 15/Apr/20 ] |
|
In order to ensure that the error message returned to drivers is always valid UTF-8, the fix merged to the master branch is to hex encode the value of the collation key (or any other invalid UTF-8) before appending it to the error message. Note that the keyValue field returned to drivers may still contain strings with invalid UTF-8. However, my understanding is that drivers currently ignore keyValue, so this should not result in errors being surfaced to the application. Since indexes with the non-simple collation store collation keys rather than raw strings, it is still the case that the value of the key exposed in the error message may not be meaningful to the user. In the future, we could consider an additional improvement which would expose the raw string whose collation key resulted in a duplicate key error. This may be more meaningful from the user's perspective. This would be a bit more complex to implement, since duplicate key errors are produced by the storage layer, which has no knowledge of the collation implementation or of the raw string that resulted in the duplicated collation key. |
| Comment by Githook User [ 15/Apr/20 ] |
|
Author: {'name': 'David Storch', 'email': 'david.storch@mongodb.com', 'username': 'dstorch'}Message: Also changes the error message to include the index's |