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

update command can make document larger than 16MB

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.6.0-rc2
    • Affects Version/s: 2.6.0-rc0
    • Component/s: Write Ops
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Hide
      var maxBsonObjectSize = db.isMaster().maxBsonObjectSize;
      var bigness = maxBsonObjectSize + 16261;
      var big_string = '';
      
      while (big_string.length < bigness) big_string += 'a';
      
      db.collection.drop();
      var result = db.runCommand({
          update: 'collection',
          ordered: true,
          updates: [
              {
                  q: {x: 1},
                  u: {$set: {s: big_string}},
                  multi: false,
                  upsert: true
              }
          ]
      });
      
      printjson(result);
      var overbigness = Object.bsonsize(db.collection.findOne()) - maxBsonObjectSize;
      print('made document ' + overbigness + ' bytes too big.')
      
      Show
      var maxBsonObjectSize = db.isMaster().maxBsonObjectSize; var bigness = maxBsonObjectSize + 16261; var big_string = ''; while (big_string.length < bigness) big_string += 'a' ; db.collection.drop(); var result = db.runCommand({ update: 'collection' , ordered: true , updates: [ { q: {x: 1}, u: {$set: {s: big_string}}, multi: false , upsert: true } ] }); printjson(result); var overbigness = Object .bsonsize(db.collection.findOne()) - maxBsonObjectSize; print( 'made document ' + overbigness + ' bytes too big.' )

      The "update" command with "upsert: true" can make documents up to 16302 bytes larger than maxBsonObjectSize.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: