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

findOne on a timeseries collection leaks ClientSession

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 5.9.1
    • Affects Version/s: None
    • Component/s: None
    • 0
    • 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?

      vkarpov15 has created PR #3889: fix: make findOne() close implicit session to avoid memory leak in node-mongodb-native

      Issue

      When constructing a find command for the findOne API, the limit is set to -1 and batchSize is set to 1. The driver's command construction logic builds a find command that includes batchSize:1,limit:1,singleBatch:true whereas pymongo builds a find command that includes only limit:1,singleBatch:true. The inclusion of batchSize:1 only when running a find against a timeseries collection will cause the reply to have a non-zero value for cursor.id. Since the value is non-zero the driver treats the cursor as still alive and the session created is never ended.

      Acceptance Criteria

      Implementation Requirements

      • store the cursor and call close on it after receiving the initial response (document or null)

      Testing Requirements

      • Run findOne against a time series collection, assert activeSessions does not grow before and after.

      Documentation Requirements

      • none

      Follow Up Requirements

      • File a server ticket about the behavior difference.

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            dbeng-pm-bot PM Bot
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: