[SERVER-72106] Clustered collections do not use correct collation when returning DuplicateKey error messages Created: 14/Dec/22  Updated: 29/Oct/23  Resolved: 03/Feb/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Louis Williams Assignee: Jordi Olivares Provencio
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2023-02-06
Participants:

 Description   

When we return DuplicateKey errors on clustered collections, we do not pass the user-provided collation, and instead, use no collation (the default).

This can result in parsing errors or returning incorrect values when duplicate keys are encountered and a collation is used.

For example

test> db.createCollection('c', {clusteredIndex: {key: {_id: 1}, unique:true}, collation: {locale: "en_US"}})
{ ok: 1 }
test> db.c.insert({_id: "hello"})
{ acknowledged: true, insertedIds: { '0': 'hello' } }
test> db.c.insert({_id: "hello"})
Uncaught:
MongoBulkWriteError: E11000 duplicate key error collection: test.c dup key: { _id: "71??E               " }
Result: BulkWriteResult {
  result: {
    ok: 1,
    writeErrors: [
      WriteError {
        err: {
          index: 0,
          code: 11000,
          errmsg: 'E11000 duplicate key error collection: test.c dup key: { _id: "71??E\x01\t\x01\t" }',
          errInfo: undefined,
          op: { _id: 'hello' }
        }
      }



 Comments   
Comment by Githook User [ 03/Feb/23 ]

Author:

{'name': 'Jordi Olivares Provencio', 'email': 'jordi.olivares-provencio@mongodb.com', 'username': 'jordiolivares'}

Message: SERVER-72106 Use user-defined collation for DuplicateKey error in clustered collection
Branch: master
https://github.com/mongodb/mongo/commit/38f0eab6dbd00e97004a2b79231772fd58118069

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