[SERVER-75242] E11000 duplicate key error cannot be understood when using Swedish collation Created: 24/Mar/23  Updated: 31/Mar/23  Resolved: 28/Mar/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 6.0.2, 6.3.0-rc2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Moqvist Assignee: Backlog - Query Execution
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-26050 Unique key violation for index with a... Backlog
Assigned Teams:
Query Execution
Operating System: ALL
Steps To Reproduce:

When using collation sv:

 

use testDb;
db.testCollection.drop();
db.createCollection("testCollection", { collation: { locale: "sv" }});
db.testCollection.createIndex({ "key": 1 }, { unique: true } );
db.testCollection.insertOne({"key":"uniquevalue"});
db.testCollection.insertOne({"key":"uniquevalue"});

Gives error message with some sort of hex value:
MongoServerError: E11000 duplicate key error collection: testDb.testCollection index: key_1 collation: { locale: "sv", caseLevel: false, caseFirst: "off", strength: 3, numericOrdering: false, alternate: "non-ignorable", maxVariable: "punct", normalization: false, backwards: false, version: "57.1" } dup key: { key: "0x51433949513153293f5131010f010f" }

 

But when using default collation it give me an understandable error message without the hex value:

use testDb;
db.testCollection.drop();
db.createCollection("testCollection");
db.testCollection.createIndex({ "key": 1 }, { unique: true } );
db.testCollection.insertOne({"key":"uniquevalue"});
db.testCollection.insertOne({"key":"uniquevalue"});

Gives error message that is easy to understand:
MongoServerError: E11000 duplicate key error collection: testDb.testCollection index: key_1 dup key: { key: "uniquevalue" }

 

Participants:

 Description   

When you have a collection with Swedish collation and a unique index and you try to insert two documents that trigger a duplicate key exception, the error message contains information that cannot be understood and linked to which document is causing the error.

 

If you have a collection without specified collation, you get an error message where you can understand which document is causing the duplicate key exception.

Is it possible to solve so that the error message for collections that do not have a default collation becomes easier to understand, so that you know which document is causing the error?

Or can I interpret the hex code myself so that it becomes readable for my users?
I can't match it against any UTF character table.



 Comments   
Comment by Ana Meza [ 28/Mar/23 ]

Closing as duplicate of SERVER-26050

Comment by Chris Kelly [ 24/Mar/23 ]

Hi daniel@prodev.se 

Thanks for your report! I'm passing this to the relevant team to take a look.

Generated at Thu Feb 08 06:29:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.