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

ChangeStream does not update resume token after resuming

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

      Running the spec test for PHPLIB-416 demonstrates a bug where ChangeStream returns the first document twice. If we modify the test to trigger three consecutive getMore failures instead of two, we see that the first document is returned three times. This seems to indicate that the resume token is not updated between successive resume attempts.

      Running the original test, we can observe the following sequence of commands via APM:

      commandStarted: aggregate
      commandSucceeded: aggregate
      
      commandStarted: getMore
      commandFailed: getMore
      
      # first fail point hit, resume is needed
      
      commandStarted: aggregate
      commandSucceeded: aggregate
      
      # after successful aggregate response, we replace the change stream's internal cursor
      # the old cursor is garbage collected, so driver sends killCursors command
      
      commandStarted: killCursors
      commandSucceeded: killCursors
      
      commandStarted: getMore
      commandFailed: getMore
      
      # second fail point hit, resume is needed
      
      commandStarted: aggregate
      commandSucceeded: aggregate
      
      # same behavior with replacing cursor after a successful resume
      
      commandStarted: killCursors
      commandSucceeded: killCursors
      
      # fail points are exhausted, so iteration proceeds (according to batchSize=1)
      
      commandStarted: getMore
      commandSucceeded: getMore
      commandStarted: getMore
      commandSucceeded: getMore
      commandStarted: getMore
      commandSucceeded: getMore
      

      We can also see that each aggregate command after the first uses the same startAtOperationTime option for $changeStream. This indicates that we're not updating the resume token properly after a resumption has taken place.

            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: