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

Support options from mongoc_query_flags_t in aggregate helpers

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: libmongoc
    • Labels:
      None

      As discovered in CDRIVER-2899, the flags passed into mongoc_collection_aggregate are not applied properly.

      For example, the following snippet appends "tailable": true to the aggregate command, causing the server to respond with an error:

      cursor = mongoc_collection_aggregate (
            collection,
            MONGOC_QUERY_TAILABLE_CURSOR,
            BCON_NEW("pipeline", "[", "]"),
            NULL,  /* additional options */
            NULL); /* read prefs, NULL for default */
      

      The tailable flag should only alter driver behavior for aggregation and not be sent as part of the aggregate or getMore commands.

      The logic leading up to appending the "tailable" field is as follows:

      • We convert the TAILABLE flag to a "tailable" bson option here
      • Then copy those options to the cursor here (and we don't exclude "tailable")
      • And then we copy those back to the aggregate command here

      We should support "tailable" and "awaitData" in the aggregate helpers. It determines whether or not we send maxTimeMS to the getMore commands on that cursor here. And users may wish to specify the tailable option if creating a change stream with the helper.

      I have not checked all other flags aside from "tailable", nor are they all applicable. For example SLAVE_OK is not applicable to mongoc_database_aggregate since SLAVE_OK is only necessary for pre-OP_MSG servers, and database aggregation was introduced after OP_MSG.

      For mongoc_database_aggregate, these options should only be passed through the bson_t opts. For mongoc_collection_aggregate they should be accepted as either flags or bson_t opts, with perhaps the bson_t opts overriding the flags.

            Assignee:
            Unassigned Unassigned
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: