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

Always invalidate ChangeStream position if iteration fails

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5.0
    • Labels:
      None

      Description

      The client throws a ResumeTokenException if it cannot extract a valid resume token. In practice, this is only relevant when connected to a pre-4.1.8 server. On server versions 4.1.8+, the server throws its own error (manifested as a ServerException) when the resume token is modified by the pipeline (SERVER-37786).

      In the case of a client-side error, the cursor position itself is still valid since resume token extraction happens at a higher level. Since ChangeStream's valid() and current() methods directly call the cursor's iteration handlers, this means that a ChangeStream created against a pre-4.1.8 server may still allow access to such a document if the application were to catch and ignore the ResumeTokenException.

      Ideally, the behavior should be consistent with the 4.1.8+ experience. We can achieve this by invalidating the ChangeStream's current position if rewind() or next() throw, and re-validating the position in onIteration() handler, which executes after a successful call to rewind() and next().

      Additionally, current() should return null if the current position is invalid. This will be consistent with how key() operates.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: