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

findAndModify with sort exceeds internal sort memory limit, silently fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8.0-rc3
    • Component/s: Concurrency
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      Start up a mongod (with mmapv1 or wiredtiger) and run the following script:

      function insert() {
          // Use 32-bit integer for representing 'length' property
          var doc = { tid: 0, length: new NumberInt(2 * 1024 * 1024 /* 2MB */) };
          doc.field = new Array(doc.length + 1).join('x');
       
          var res = db.foo.insert(doc);
          assert.writeOK(res);
          assert.eq(1, res.nInserted);
      }
       
      function findAndModify() {
          var res = db.runCommand({
              findandmodify: db.foo.getName(),
              query: { tid: 0 },
              sort: { length: 1 }, // NOTE: this seems necessary for the repro
              update: { $mul: { length: 1 } },
              new: true
          });
          assert.commandWorked(res);
       
          var doc = res.value;
          assert(doc !== null, 'query spec should have matched a document');
      }
       
      db.foo.drop();
      while (true) {
          insert();
          findAndModify();
      }

      Show
      Start up a mongod (with mmapv1 or wiredtiger) and run the following script: function insert() { // Use 32-bit integer for representing 'length' property var doc = { tid: 0, length: new NumberInt(2 * 1024 * 1024 /* 2MB */) }; doc.field = new Array(doc.length + 1).join('x');   var res = db.foo.insert(doc); assert.writeOK(res); assert.eq(1, res.nInserted); }   function findAndModify() { var res = db.runCommand({ findandmodify: db.foo.getName(), query: { tid: 0 }, sort: { length: 1 }, // NOTE: this seems necessary for the repro update: { $mul: { length: 1 } }, new: true }); assert.commandWorked(res);   var doc = res.value; assert(doc !== null, 'query spec should have matched a document'); }   db.foo.drop(); while (true) { insert(); findAndModify(); }

      Description

      When performing insert operations between findAndModify commands, a findAndModify will eventually fail to find a document to update, even though the query predicate remains the same. This failure only seems to occur when a sort specification is supplied.


      git version
      a6788ec72a9dabb38bd92a8ab653e32034e9e02e

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: