Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-10146

cursor id of aggregate reply not set

      1. module info:

      db version v3.2.4
      git version: nogitversion
      allocator: tcmalloc
      modules: none
      build environment:
          distarch: x86_64
          target_arch: x86_64
      

      2. issue info

      The following is the OP_REPLY struct of mongodb wire protocol.

      _struct {
          MsgHeader header;         // standard message header
          int32     responseFlags;  // bit vector - see details below
          int64     cursorID;       // cursor id if client needs to do get more's
          int32     startingFrom;   // where in the cursor this reply is starting
          int32     numberReturned; // number of documents in the reply
          document* documents;      // documents
      }_
      

      When the cursorID is set to non-zero in a reply, it implies there are more data, and client should do get more's.

      However, the cursorID is always set to zero in replies of aggregate request, even if there are more data. Actually the cursor id is set in the "documents"..

      This behavior is not following the standard protocol.

      3. request&reply info

      the request is like that:

      ??
      [
         {
            "$match" : {
               "_isdelete" : 0,
               "_uid" : 444629226
            }
         },
         {
            "$group" : {
               "ctime" : {
                  "$max" : "$ctime"
               },
               "_id" : {
                  "name" : "$name"
               }
            }
         },
         {
            "$sort" : {
               "_id" : 1
            }
         },
         {
            "$skip" : 0
         },
         {
            "$limit" : 400
         }
      ]
      ??
      

      the reply bytes is like that:

      messageLength: 40263
      requestID:125067217
      responseTo:9
      opCode: OP_REPLY
      responseFlags:0x4
      cursorID:0
      startingFrom:0
      numberReturned: 1
      documents: {
           "waitedMS":0, 
           "cursor": {
               "id":22321923528,
               "ns": "test.test0"
               "firstBatch": ...
      }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            licen Cen Li
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              1 year, 24 weeks, 4 days ago