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

E11000 (duplicate key error) should return a list of duplicate keys and _ids in insert, bulk insert, and continue_on_error inserts.

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 2.0.2
    • Fix Version/s: Backlog
    • Component/s: Index Maintenance
    • Labels:
      None
    • Case:

      Description

      The current output is like this:

      {"err"=>"E11000 duplicate key error index: ruby-test-db.test.$foo_1 dup key: { : 3 }", "code": 11000, "n": 0, "connectionId": 58, "ok": 1.0}

      Three problems:
      1. The duplicate key is specified as part of a string.
      2. Only the latest duplicate key is given. On a bulk insert with continue_on_error, we should get a list containing all duplicate keys found.
      3. If we're given only the duplicate keys, it's hard to be sure which documents were inserted. For that, we also need the _ids of the documents that were rejected.

      Here's the ideal output:

      {"err"=>"E11000 duplicate key error index: ruby-test-db.test.$foo_1 dup keys: [3, 4]",
      "keys": [3, 4], rejected_ids: [ObjectId("4f071fbe935f46ab13686625"), ObjectId("4f071fbe935f46ab13686627")],
      "code": 11000, "n": 0, "connectionId": 58, "ok": 1.0
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              michael.gargiulo Michael Gargiulo
              Reporter:
              kbanker Kyle Banker
              Participants:
              Votes:
              26 Vote for this issue
              Watchers:
              18 Start watching this issue

                Dates

                Created:
                Updated: