Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-441

ChangeStream key offset is not advanced when resuming

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.3
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      When originally implementing the change stream spec test runner, I iterated the change stream using iterator_to_array(). This would normally be OK for the purposes of the spec test, since the runner opens a change stream, perform all operations in sequence, and finally iterates the change stream to collected events for those operations. As there is no need to watch the change stream for future events, it's acceptable that iterator_to_array() stops when valid() returns false (i.e. no more events available).

      The default behavior of iterator_to_array() preserves keys from the iterator. In the test where the change stream resumes after a getMore failure, this results in the original event (returned by aggregate) being overwritten. Since a ChangeStream only replaces its inner iterator when resuming, I don't believe this is caused by the $key property being reset (the ChangeStream instance remains the same). Rather, I think the issue is that we're not incrementing $key properly.

      Although we can work around this by the $use_keys option for iterator_to_array(), it is hardly intuitive and it'd be preferable to fix the increment behavior.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: