[CDRIVER-3031] Support options from mongoc_query_flags_t in aggregate helpers Created: 20/Mar/19  Updated: 31/Mar/22

Status: Backlog
Project: C Driver
Component/s: libmongoc
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Kevin Albertson Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-3032 Audit how options are applied in curs... Backlog

 Description   

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.



 Comments   
Comment by Githook User [ 23/Aug/19 ]

Author:

{'name': 'isabelatkinson', 'email': 'isabelatkinson@gmail.com', 'username': 'isabelatkinson'}

Message: CDRIVER-3031 support tailable flag in aggregate helper
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/b37f263e2286ad20c656df1e96fa106377fd7c7a

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