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.
- is depended on by
-
PHPC-1128 Aggregation pipelines are broken on sharded collections
- Closed
- is related to
-
CDRIVER-2348 New API for setting awaitData and tailable on command cursors
- Closed
- related to
-
CDRIVER-2518 Implement mongoc_cursor_new_from_command_reply_with_opts()
- Closed