Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-1029

Support maxTimeMS getMore option for tailable command cursors

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.0-beta1, 1.4.0
    • 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.

            Assignee:
            derick Derick Rethans
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: