Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2517

Aggregation on sharded cluster fails when $gleStats is used as a cursor option

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.9.3, 1.10.0
    • Affects Version/s: 1.9.0
    • Component/s: None
    • None
    • Environment:
      mongod/mongos 3.4.9

      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.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: