[CDRIVER-2517] Aggregation on sharded cluster fails when $gleStats is used as a cursor option Created: 22/Feb/18  Updated: 28/Oct/23  Resolved: 26/Feb/18

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.9.0
Fix Version/s: 1.9.3, 1.10.0

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Jeremy Mikola
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mongod/mongos 3.4.9


Issue Links:
Depends
is depended on by PHPC-1128 Aggregation pipelines are broken on s... Closed
Related
related to CDRIVER-2518 Implement mongoc_cursor_new_from_comm... Closed
is related to CDRIVER-2348 New API for setting awaitData and tai... Closed

 Description   

In PHPC-1128, a user reported seeing the following error when attempting to run an aggregation pipeline on a sharded cluster:

Cannot use $-modifiers in opts: "$gleStats"

I traced this error to _mongoc_cursor_new_with_opts(), called by mongoc_cursor_new_from_command_reply(), which we call when constructing the cursor for a command response.

This error does not appear in versions of the PHP driver before 1.4.0 (libmongoc 1.9.2), so I believe it originated with 25ee119 for CDRIVER-2348. In earlier versions of libmongoc, the only the cursor ID and reply array were considered in the command response. Since that commit, other fields are now incorporated as cursor options.

Since the logic in mongoc_cursor_new_from_command_reply() does exclude certain fields before copying the reply document into a new BSON document for cursor options, I wonder if it should be enhanced to ignore all $-prefixed fields (which would trigger the same error in _mongoc_cursor_new_with_opts()), or at least $gleStats (as it does $clusterTime).

There isn't much documentation on the $gleStats available, but SERVER-20265 does hint at its purpose as a sharding-specific field.



 Comments   
Comment by Githook User [ 02/Mar/18 ]

Author:

{'email': 'jmikola@gmail.com', 'name': 'Jeremy Mikola', 'username': 'jmikola'}

Message: CDRIVER-2517 ignore $gleStats creating cursor from command reply
Branch: debian
https://github.com/mongodb/mongo-c-driver/commit/5602c585b231ddcc317930528c5331da749c9f38

Comment by Githook User [ 02/Mar/18 ]

Author:

{'email': 'jmikola@gmail.com', 'name': 'Jeremy Mikola', 'username': 'jmikola'}

Message: CDRIVER-2517 ignore $gleStats creating cursor from command reply
Branch: r1.9-dfsg
https://github.com/mongodb/mongo-c-driver/commit/5602c585b231ddcc317930528c5331da749c9f38

Comment by Githook User [ 26/Feb/18 ]

Author:

{'email': 'jmikola@gmail.com', 'name': 'Jeremy Mikola', 'username': 'jmikola'}

Message: CDRIVER-2517 ignore $gleStats creating cursor from command reply
Branch: r1.9
https://github.com/mongodb/mongo-c-driver/commit/5602c585b231ddcc317930528c5331da749c9f38

Comment by Githook User [ 26/Feb/18 ]

Author:

{'email': 'jmikola@gmail.com', 'name': 'Jeremy Mikola', 'username': 'jmikola'}

Message: CDRIVER-2517 ignore $gleStats creating cursor from command reply
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/e56ab17f888852cd4c94fdcdfca284f443d02c60

Generated at Wed Feb 07 21:15:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.