Do not resume after change stream cursor is closed

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor - P4
    • 2.2.0
    • Affects Version/s: None
    • Component/s: None
    • Not Needed
    • 🔵 Done
    • Completed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Attempting to iterate a closed change stream results in the server error:

      Attempting to resume a change stream using 'resumeAfter' is not allowed from an invalidate notification.
      

      Proposed Change: Do not attempt to resume the change stream. Return an error message indicating the change stream is closed.

      Consider: Compare behavior with other driver behavior when iterating a closed change stream cursor. Consider filing a DRIVERS ticket to specify a change stream must not attempt to resume after closed.

      How to Reproduce

      This branch includes a failing test to reproduce the error: https://github.com/mongodb/mongo-c-driver/compare/master...kevinAlbs:mongo-c-driver:changestream

      Additional Background

      The server signals a change stream is closed by responding with a 0 cursor ID. Example:

      { "cursor" : { "id" : 0, "ns" : "db.coll", "nextBatch" : [  ], "postBatchResumeToken" : { "_data" : "826516E9230000000F2B042C0100296F5A1004A9D70E866B784600A7165560BE721BF2463C6F7065726174696F6E54797065003C64726F70000004" } }, "ok" : 1.0, "$clusterTime" : { "clusterTime" : { "$timestamp" : { "t" : 1696000291, "i" : 23 } }, "signature" : { "hash" : { "$binary" : { "base64" : "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType" : "00" } }, "keyId" : 0 } }, "operationTime" : { "$timestamp" : { "t" : 1696000291, "i" : 23 } } }
      

      The C driver mongoc_cursor_t returns this error when iterating a closed mongoc_cursor_t:

      Cannot advance a completed or failed cursor
      

      The Go driver ChangeStream checks for a cursor ID of 0. returns false to signal no events are returned, and does not attempt to resume or return an error.

            Assignee:
            Julia Garland
            Reporter:
            Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: