[CDRIVER-2348] New API for setting awaitData and tailable on command cursors Created: 07/Nov/17  Updated: 28/Oct/23  Resolved: 13/Nov/17

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

Type: Task Priority: Major - P3
Reporter: Derick Rethans Assignee: A. Jesse Jiryu Davis
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 PHPC-1029 Support maxTimeMS getMore option for ... Closed
Related
related to CDRIVER-2517 Aggregation on sharded cluster fails ... Closed

 Description   

For PHPC-1029, we need an API so that we can set tailable and awaitData on the command cursor that is created from the envelope that's returned. PHP uses mongoc_cursor_new_from_command_reply(), which allows no way to set tailable/awaitData options, which are required for mongoc_cursor_set_max_await_time_ms() to have any effect.



 Comments   
Comment by Githook User [ 13/Nov/17 ]

Author:

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

Message: CDRIVER-2348 cursor_new_from_command_reply options

Accept "tailable", "awaitData" and other command options.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/25ee1193b5e343eea9edd32c4016101aec9a0961

Comment by Kevin Albertson [ 09/Nov/17 ]

Yes it is. But I think the only differing behavior on the drivers side when tailable/awaitData is set on an aggregate command is whether maxTimeMS is sent.

Comment by Derick Rethans [ 09/Nov/17 ]

Kevin, I am not sure whether that would actually work, as a ChangeStream cursor logically is a tailable and await_data cursor?

Comment by Kevin Albertson [ 09/Nov/17 ]

I also prefer #1.

Not sure if this was discussed yet. One thing jmikola mentioned in slack was the "most minimal might be allowing maxTimeMS to be passed to getmore irrespective of tailable/awaitData options on original cursor". I.e. removing the if here. Was that ruled out?

Comment by Derick Rethans [ 09/Nov/17 ]

I favour #1, as that seems the most flexible, and doesn't require a new symbol that we'd need to maintain.

Comment by A. Jesse Jiryu Davis [ 07/Nov/17 ]

A couple of options. Do you have an opinion?:

1. Extend mongoc_cursor_new_from_command_reply to understand new BSON fields in the passed-in "reply" parameter. So you could add fields to the "find" reply before passing it in:

{
	"ok" : 1,
	"cursor" : {
		"id" : NumberLong(0),
		"ns" : "test.collection",
		"firstBatch" : [ ... ]
	},
        "awaitData": true,
        "tailable": true
}

2. New function:

mongoc_cursor_t *
mongoc_cursor_new_with_opts (bson_t *opts);

The "opts" there would accept options "cursor" (the same cursor document as above), "awaitData", and "tailable".
3. Add mongoc_cursor_set_cursor_type() that takes a bitfield or something, with bits TAILABLE and AWAIT_DATA.

I'm partial to #1.

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