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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 6.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Execution
    • Fully Compatible
    • ALL
    • Execution Team 2023-02-06
    • None
    • None
    • None
    • None
    • None
    • None
    • None

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

            Assignee:
            Jordi Olivares Provencio
            Reporter:
            Louis Williams
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: