-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
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.
- is related to
-
SERVER-82274 singleBatch find on a timeseries collection does not close cursor if batchSize is set
- Closed