[SERVER-3090] Add the ability to list open cursors Created: 13/May/11  Updated: 07/Apr/23  Resolved: 12/Oct/18

Status: Closed
Project: Core Server
Component/s: Admin, Diagnostics, Querying
Affects Version/s: None
Fix Version/s: 4.1.5

Type: New Feature Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 78
Labels: asya, commands, diagnostics, lntrospection
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-14047 endless "moveChunk failed, because t... Closed
Documented
is documented by DOCS-12147 Docs for SERVER-3090: Add the ability... Closed
Duplicate
is duplicated by SERVER-5816 Add command to get a list of open cur... Closed
is duplicated by SERVER-1919 cursor info option to get detailed in... Closed
Related
related to SERVER-5813 Create a shell helper to kill a curso... Closed
related to SERVER-19982 Log diagnostic message when creating ... Backlog
Assigned Teams:
Query
Backwards Compatibility: Fully Compatible
Sprint: Query 2018-07-16, Query 2018-07-30
Participants:
Case:

 Description   

Allow access to the list of active cursors.

This should allow returning something like this:

> db.runCommand("listCursors")
{ ok:1.0,
 cursors: [
    {
	id:..., 
	ns:..., 
	query:..., 
	client:..., 
	created:...., 
	lastAccess:..., 
	noTimeout:.., 
	timeoutInMS:..., 
	runningMS:...,
	yieldNum:...,  
	user:..., 
	nReturned:..., 
	nPosition:..., 
	...} //recordStats/locks/curOp-info/etc
  ]
}

This command should be user-aware and only return cursors for the active user.

Paramters:

name value desc/behavior
filter <any query filter>, {id:###} This should allow a filter/match param to reduce the total set of cursors returned.
ns/db   filters to this ns/db – command name value is the default for this if not true-ish
user <current> This command should be user-aware and only return cursors for the active user. Optionally this should allow overriding to return all user info if the user has privs


 Comments   
Comment by Ted Tuckman [ 12/Oct/18 ]

In the upcoming 4.1.5 release the currentOp aggregation stage will be able to list idleCursors. If "idleCursors: true" is passed to currentOp, each cursor will get one document in the output with "type: idleCursor." Example: 

db.aggregate([{$currentOp: {idleCursors: true}}])

In addition, during an active operation the "type: op" document will have a cursor field with information about the cursor it is using if it is using a cursor. 

 

More extensive documentation of this feature will be provided in the future. To see the current documentation of the $currentOp stage, click here.

Comment by Lucas [ 08/Feb/18 ]

We definitely need this

Comment by Itso Slavchev [ 06/Jun/17 ]

Would love to have the ability to get a list of open noTimeout cursors too.. Also having troubles with identifying the root cause for our ever growing number of open cursors.

Comment by David Storch [ 09/Jan/17 ]

ssimpson@elance-odesk.com, this currently has a fixVersion of "planned but not scheduled". This means that it is work which we would like to do, but it is not yet targeted for any particular version.

Comment by Scott Simpson [ 07/Jan/17 ]

We need this now. On any roadmap? Seems like it would be easy to implement.

Comment by Glen Miner [ 27/May/15 ]

This would really, really help us try to avoid problems causing https://jira.mongodb.org/browse/SERVER-17364 which is causing us increasing anxiety – is there any other way to list cursors in a way that might help us track down where the leak is coming from?

Comment by Antoine Girbal [ 14/May/13 ]

we should also add a killCursor command, that does the same thing as the wire protocol kill cursor.
It would be 1 less thing to implement at a low level in drivers.
Also could make it easier for security handling.

Comment by Scott Hernandez (Inactive) [ 13/May/11 ]

If you ever want the client to be able to cleanup cursors (like a purge), then yes; the drivers have bugs where they don't cleanup – we have seen this many times.

It seems like for no other reason than at the moment you can't get a list of the current (no_timeout) cursors. Would you rather create a special $collection instead?

Comment by Dwight Merriman [ 13/May/11 ]

is this needed?

Generated at Thu Feb 08 03:02:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.