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

Parameter 'limit' is not supported for exhaust queries in Mongo Shell

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 6.1.0-rc0
    • Affects Version/s: 6.1.0-rc0
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • Hide
      var coll = db.exhaustColl;
      coll.drop();
      
      // Include a long string in each document so that the documents are a bit bigger than 16KB.
      const strSize = 16 * 1024;
      // The docs are ~16KB and each getMore response is 16MB. Therefore, a full getMore batch will
      // contain about 1000 documents. Since the initial find response is limited to only 101 documents,
      // by inserting 3000 we ensure that three subsequent getMore replies are required. Roughly speaking,
      // the initial reply will consist of the first 100, the first getMore reply 1000 more, then another
      // 1000, and then the remaining 900.
      const numDocs = 3000;
      
      const str = "A".repeat(strSize);
      
      let bulk = coll.initializeUnorderedBulkOp();
      for (let i = 0; i < numDocs; ++i) {
          bulk.insert({key: str});
      }
      assert.commandWorked(bulk.execute());
      
      assert.eq(numDocs, coll.find().limit(10000).addOption(DBQuery.Option.exhaust).itcount());
      

      Result:

      Error: Cannot have limit for exhaust query
      
      Show
      var coll = db.exhaustColl; coll.drop(); // Include a long string in each document so that the documents are a bit bigger than 16KB. const strSize = 16 * 1024; // The docs are ~16KB and each getMore response is 16MB. Therefore, a full getMore batch will // contain about 1000 documents. Since the initial find response is limited to only 101 documents, // by inserting 3000 we ensure that three subsequent getMore replies are required. Roughly speaking, // the initial reply will consist of the first 100, the first getMore reply 1000 more, then another // 1000, and then the remaining 900. const numDocs = 3000; const str = "A" .repeat(strSize); let bulk = coll.initializeUnorderedBulkOp(); for (let i = 0; i < numDocs; ++i) { bulk.insert({key: str}); } assert .commandWorked(bulk.execute()); assert .eq(numDocs, coll.find().limit(10000).addOption(DBQuery.Option.exhaust).itcount()); Result: Error: Cannot have limit for exhaust query
    • QE 2022-05-16, QE 2022-05-30, QE 2022-06-13
    • 15

      Parameter 'limit' is not supported for exhaust queries in Mongo Shell. Negative 'limit' parameter values should be support to keep parity to non-exhaust queries.

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            mindaugas.malinauskas@mongodb.com Mindaugas Malinauskas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: