Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-72106

Clustered collections do not use correct collation when returning DuplicateKey error messages

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • None
    • None
    • None
    • Storage Execution
    • Fully Compatible
    • ALL
    • Execution Team 2023-02-06

    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' }
              }
            }
      

      Attachments

        Activity

          People

            jordi.olivares-provencio@mongodb.com Jordi Olivares Provencio
            louis.williams@mongodb.com Louis Williams
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: