Search code examples
mongodbtimeoutpymongodatabase-cursor

How to kill dead cursors in MongoDB


When querying a MongoDB collection, if the read will take a while, the cursor times out. There's a timeout=False option, which makes the cursor not time out, and then it must be closed manually.

When a script crashes with an open cursor, that cursor presumably just stays alive in the DB until the next restart. In the MMS monitoring dashboard, these are visible as a high constant in the "cursors" chart.

mms cursors

What are the consequences of this? And how can I kill these cursors manually?


Solution

  • As noted by wdberkeley, this doesn't currently exist, but is a new feature requested in https://jira.mongodb.org/browse/SERVER-3090.