[CXX-1564] Cannot set use_cursor or batch_size with aggregation cursor Created: 23/Apr/18  Updated: 28/Oct/23  Resolved: 18/May/18

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: 3.2.0
Fix Version/s: 3.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CXX-1552 Drop MongoDB 2.6 Closed
is related to CXX-1485 Deprecate methods and classes relate... Closed

 Description   

After upgrading to C Driver 1.9.0, the C++ Driver can no longer set use_cursor or batch_size with options::aggregate. If it sets only batch_size, the batch_size is not actually sent with the initial aggregate command. If it sets use_cursor, then the "cursor" field is included in the aggregate command twice, causing a server error.

The problem arose when the C Driver dropped support for old MongoDB versions. Its aggregate logic changed to always include the cursor field. This obsoletes the C++ driver's use_cursor option and violates the C++ driver's assumption about how to pass batch_size field.

Remove the use_cursor option, and if batch_size is set then add the "batchSize" field directly to the top level of the "opts" BSON document passed to mongoc_collection_aggregate, rather than wrapping it in a "cursor" document.



 Comments   
Comment by Githook User [ 18/May/18 ]

Author:

{'username': 'ajdavis', 'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com'}

Message: CXX-1564 Reenable options::aggregate::batch_size
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/ae46c1dbb002207a5a4762876643e65178a4c44e

Comment by A. Jesse Jiryu Davis [ 23/Apr/18 ]

Once done, in test/sessions.cpp set the aggregate batch size to 2 so we can be certain that the right lsid is sent with the aggregate command's getMore. Add to the aggregate section:

        // An aggregate and a getMore.
        REQUIRE(test.events.size() >= 2);

Also add asserts in this section in collection_mocked.cpp:

SECTION("Aggregate", "[Collection::aggregate]")

Generated at Wed Feb 07 22:03:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.