[CDRIVER-2886] Aggregate command must be sent to a primary if it uses $out Created: 15/Nov/18  Updated: 28/Oct/23  Resolved: 08/Mar/19

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

Type: New Feature Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Clyde Bazile III (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CXX-1696 Aggregate command must be sent to a p... Closed
is depended on by DRIVERS-582 Aggregate command must be sent to a p... Closed

 Description   

See DRIVERS-582 for details.



 Comments   
Comment by Githook User [ 08/Mar/19 ]

Author:

{'name': 'bazile-clyde', 'email': '34226620+bazile-clyde@users.noreply.github.com', 'username': 'bazile-clyde'}

Message: CDRIVER-2886 Agg cmd must be sent to a primary if it uses $out
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/46899fa9bb71633cb50cb0d05a8038d4e776fbbd

Comment by Kevin Albertson [ 28/Feb/19 ]

mongoc_collection_aggregate is lazy. It won't actually send the aggregate command to the server until the returned cursor is iterated on the first time with mongoc_cursor_next.

We select the server to run the initial aggregate command inside our cursor logic here:
https://github.com/mongodb/mongo-c-driver/blob/master/src/libmongoc/src/mongoc/mongoc-cursor.c#L641-L676

We likely need to indicate on the mongoc_cursor_t (perhaps with a boolean flag) that we need to use a primary. And then set that boolean flag in mongoc_cursor_aggregate if the pipeline has a $out stage.

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