[DOCS-10146] cursor id of aggregate reply not set Created: 29/Mar/17  Updated: 30/Oct/23

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: Cen Li Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 1 year, 14 weeks, 2 days ago
Epic Link: DOCSP-1769

 Description   

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": ...
}



 Comments   
Comment by Education Bot [ 31/Oct/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

Comment by Cen Li [ 27/Apr/17 ]

Hi Thomas,

Thx for your clarification.

Brs,
Cen

Comment by Kelsey Schubert [ 19/Apr/17 ]

Hi licen,

Sorry for the delay getting back to you. For non-legacy opqueries, we use the wire protocol slightly differently, and include the cursor id within the documents field as shown in your description. This behavior is expected by MongoDB drivers. For example, in PyMongo, you can review the source code:

https://github.com/mongodb/mongo-python-driver/blob/3.4.0/pymongo/collection.py#L1876-L1886
https://github.com/mongodb/mongo-python-driver/blob/3.4.0/pymongo/command_cursor.py#L35-L43

I've moved this ticket to the DOCS project as an improvement request to clarify the wire protocol in our documentation.

Thank you,
Thomas

Generated at Thu Feb 08 07:59:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.