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

For a find request with batchSize equal to the limit size, the mongos of the sharded cluster will return a cursorid not equal to 0, the client will send an extra getMore, and no data is returned

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None
    • Query Execution

    Description

       For a sharded cluster, when a find request with a limit equal to batchSize is sent to mongos, the returned cursorid is not 0, like this:

       

      mongos> db.runCommand({find:"coll", limit:1, batchSize:1})
      {
              "cursor" : {
                      "firstBatch" : [
                              {
                                      "_id" : ObjectId("62e38b2509f1b4519551f9d1"),
                                      "a" : 1
                              }
                      ],
                      "id" : NumberLong("1810946290033139346"),
                      "ns" : "mydb.coll"
              },
              "ok" : 1,
              "operationTime" : Timestamp(1659496263, 1),
              "$clusterTime" : {
                      "clusterTime" : Timestamp(1659496269, 2),
                      "signature" : {
                              "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                              "keyId" : NumberLong(0)
                      }
              }
      } 

      Then the client will send a getMore request, but get empty data.
       
      From the code of mongos, if the conditions of firstBatch are met, the logic of judging whether clusterClientCursor is EOF will not be entered, so the cursor id will still be brought into the returned result. 
      code
       
       
      The second getMore request is unnecessary. Is it possible to make the cursorid returned by the first find request to be 0?
       

       

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            1321280378feng@gmail.com Chao Yin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: