Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5044

Write Concern 0 Must Not Affect Read Operations [5.x]

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.2.0
    • Affects Version/s: 4.13.0, 5.0.0
    • Component/s: None
    • 2
    • Not Needed
    • Not Needed
    • 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?

      When the driver has a write concern of 0 it does not apply the lsid to any initial command, including reads. This causes issues with cursors as the initial find command does not have an lsid attached but the subsequent getMore commands do. This causes an error on the server: "Cannot run getMore on cursor x, which was not created in a session...".

      Steps to reproduce:

      • Create a client with writeConcern 0.
      • Insert documents into a collection more than the default batch size
      • Execute collection.find({}).toArray() to run the find and at least one getMore

      The sessions spec states the lsid MUST be sent on all commands with 1 exception being unacknowledged writes - the driver is improperly treating reads the same here: https://github.com/mongodb/node-mongodb-native/blob/main/src/sessions.ts#L960

      Open question: What should be the behaviour for the generic run command?

      Cloned this from the original. This bug still persists in 5.x, we need a forward port

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: