-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
MongoDB\Driver\Query supports a maxAwaitTimeMS option in conjunction with tailable and awaitData. If set, that option is assigned to the libmongoc cursor via mongoc_cursor_set_max_await_time_ms() before it is ever sent to the server (and likewise before we check the executed query for an error and construct the resulting MongoDB\Driver\Cursor). Once set on the cursor, this option is then used for the maxTimeMS option on ensuing getMore commands during iteration between batches.
With change streams, the aggregate command can now return a tailable cursor. The initial command response will still contain the envelope for a command cursor (e.g. cursor ID, first batch), but the resulting command cursor created from that envelope will be tailable. The change stream spec also defines a maxAwaitTimeMS option, which shall be used to specify the maxTimeMS option on getMore commands issued while iterating the tailable cursor.
In order to support this, MongoDB\Driver\Command should accept an options array as its second argument (as Query currently does). A maxAwaitTimeMS option can then be specified, which the driver may use to assign to the command cursor created after unpacking the cursor envelope by calling mongoc_cursor_set_max_await_time_ms(). This is similar to what we do for query cursors, but will need to happen after we initialize the command cursor.
Note that the driver will also need to set the tailable and awaitData options on the command cursor (again, the cursor we init after unpacking) if also assigning maxAwaitTimeMS, as libmongoc first checks those options when preparing a getMore command.
- depends on
-
CDRIVER-2348 New API for setting awaitData and tailable on command cursors
- Closed
- is depended on by
-
PHPLIB-276 Change stream support
- Closed
- related to
-
PHPC-1109 Support batchSize getMore option for command cursors
- Closed