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

"listCollections" command fails with BSONObjectTooLarge error

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0, 6.0.6, 5.0.17, 4.4.21, 6.3.1
    • Affects Version/s: 5.0.15, 6.0.5
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v6.3, v6.0, v5.0, v4.4, v4.2
    • Hide
      (function() {
      "use strict";
      
      const validatorObj = {
      $jsonSchema: {
      bsonType: "object",
      properties: {
      s: {bsonType: "string", description: "x".repeat(4801)},
      
      }
      }
      };
      
      const nCollections = 3300;
      assert.commandWorked(db.dropDatabase());
      jsTestLog(`Creating ${nCollections} collections....`);
      for (let i = 0; i < nCollections; i++) {
      assert.commandWorked(db.createCollection("c_" + i.toPrecision(6), {"validator": validatorObj}));
      }
      jsTestLog(`Done creating ${nCollections} collections`);
      const res = db.runCommand({"listCollections": 1});
      assert.commandWorked(res);
      }());
      Show
      (function() { "use strict" ; const validatorObj = { $jsonSchema: { bsonType: "object" , properties: { s: {bsonType: "string" , description: "x" .repeat(4801)}, } } }; const nCollections = 3300; assert .commandWorked(db.dropDatabase()); jsTestLog(`Creating ${nCollections} collections....`); for (let i = 0; i < nCollections; i++) { assert .commandWorked(db.createCollection( "c_" + i.toPrecision(6), { "validator" : validatorObj})); } jsTestLog(`Done creating ${nCollections} collections`); const res = db.runCommand({ "listCollections" : 1}); assert .commandWorked(res); }());
    • QE 2023-04-03

      "listCollections" command fails with BSONObjectTooLarge error when:

      1. the batch size is not specified or is large enough;
      2. the number of entries to return is larger than approximately 3300;
      3. total BSON size of entries to return approaches 16MB.

      Likely other commands such as "find" and "aggregate" are affected.

      Extremely likely the root cause is not accounting for array element field element size when building the result.

            Assignee:
            mindaugas.malinauskas@mongodb.com Mindaugas Malinauskas
            Reporter:
            mindaugas.malinauskas@mongodb.com Mindaugas Malinauskas
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: