christkv/node-mongodb-native — Issue #497: Collection.find with a limit leaks cursors when db.authenticate is used
Author: megaphone
Created: 2012-02-03 21:37:50+00:00
State: open

While doing load testing on heroku with mongohq we noticed that the total open cursors count started increasing without bounds. This only happens when we run mongo with auth=true and use db.authenticate. The cursors are not closed when the limit is greater than 1 and less than the number of documents in the collection.

Tested with node 0.4.7, mongo 2.0.2 and node-mongodb-native 0.9.8-5

We have replicated this on Heroku with MongoHQ as well as our own EC2 instance running mongodb locally.

When the issue occurs we see the following line in the mongodb log with verbose=true with each request:

Fri Feb 3 21:28:20 [conn16] query mongodb_name.collection_name ntoreturn:2 nreturned:2 reslen:64 0ms
Fri Feb 3 21:28:20 [conn16] killcursors 0ms

When the issue does not occur we only see the query line and not the killcursors line.

We create a test case application to reproduce the issue: https://github.com/megaphone/megacase