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

The doTxn command doesn't error when inserting a document that already exists

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Replication
    • None
    • Replication
    • ALL
    • Hide

      (function() {
          const coll = db.mycoll;
          coll.drop();
       
          assert.commandWorked(db.runCommand({create: coll.getName()}));
          assert.commandFailedWithCode(db.adminCommand({
              applyOps: [
                  {op: "i", ns: coll.getFullName(), o: {_id: 1}},
                  {op: "i", ns: coll.getFullName(), o: {_id: 1}},
              ]
          }),
                                       ErrorCodes.DuplicateKey);
       
      })();
      

      Show
      ( function () { const coll = db.mycoll; coll.drop();   assert.commandWorked(db.runCommand({create: coll.getName()})); assert.commandFailedWithCode(db.adminCommand({ applyOps: [ {op: "i" , ns: coll.getFullName(), o: {_id: 1}}, {op: "i" , ns: coll.getFullName(), o: {_id: 1}}, ] }), ErrorCodes.DuplicateKey);   })();

    Description

      This means operations of type op='i' aren't equivalent to an insert command of the same document. I suspect this is just because the "doTxn" has implicitly inherited some of the idempotency behaviors by leveraging the applyOperation_inlock() machinery.

      Attachments

        Activity

          People

            backlog-server-repl Backlog - Replication Team
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: