[SERVER-8188] Configurable idle cursor timeout Created: 14/Jan/13  Updated: 07/Jun/19  Resolved: 13/Mar/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 2.6.9, 3.0.2, 3.1.0

Type: Improvement Priority: Major - P3
Reporter: Ben McCann Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 10
Labels: cursor, cursors
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to SERVER-15042 Add noCursorTimeout option to command... Closed
related to DOCS-5027 Document configurable idle cursor tim... Closed
related to DOCS-4164 Cursor do not keep alive in a sharded... Closed
related to SERVER-6036 Disable cursor timeout for cursors th... Closed
Backwards Compatibility: Fully Compatible
Backport Completed:
Participants:

 Description   
Issue Status as of Mar 17, 2015

ISSUE SUMMARY
Client cursors that are no longer used may not be closed by the server. These cursors continue to consume resources inside mongod. By default, inactive cursors expire after 10 minutes, this option makes it possible to configure this timeout.

RESOLUTION DETAILS
By specifing the cursorTimeoutMillis option, administrators can configure mongod or mongos to automatically remove idle client cursors after a specified interval. The timeout applies to all cursors maintained on a mongod or mongos, may be specified when starting the mongod or mongos and may be modified at any time using the setParameter command. Consider the following examples.

On startup:

mongod --setParameter cursorTimeoutMillis=<num>

or:

mongos --setParameter cursorTimeoutMillis=<num>

During operation, using the mongo shell:

use admin
db.runCommand({setParameter:1, cursorTimeoutMillis: <num>})

Original description

The only options for timeout are 10 minutes or disabled. It would be very nice to be able to set this to other lengths of time.



 Comments   
Comment by Githook User [ 25/Mar/15 ]

Author:

{u'username': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-8188: make cursor timeout configurable on server

(cherry picked from commit 4d7b131c5454bf56fd494b1a3537eeb5e221a027)
Branch: v3.0
https://github.com/mongodb/mongo/commit/d9a3c65f642ce90b1cf6f725786654998676cd20

Comment by Githook User [ 13/Mar/15 ]

Author:

{u'username': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-8188: make cursor timeout configurable on server

(cherry picked from commit 4d7b131c5454bf56fd494b1a3537eeb5e221a027)
Branch: v2.6
https://github.com/mongodb/mongo/commit/e3a769273df9e1217a9c85d067db058e4293952f

Comment by Githook User [ 13/Mar/15 ]

Author:

{u'username': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-8188: make cursor timeout configurable on server
Branch: master
https://github.com/mongodb/mongo/commit/4d7b131c5454bf56fd494b1a3537eeb5e221a027

Comment by Daniel Pasette (Inactive) [ 18/Jun/14 ]

Thanks Ben. I updated the ticket slightly to better reflect the request.

Comment by Ben McCann [ 18/Jun/14 ]

We have some jobs that do heavy data processing. We grab a bunch of records from MongoDB, do some processing, grab more records. If that processing takes too long then sometimes the cursor times out. We can set it to never, but that doesn't seem like a great idea. If our client crashes before exhausting the cursor then it'll just live on the server forever.

Comment by Daniel Pasette (Inactive) [ 18/Jun/14 ]

Idle cursors is a server side concept. By default, idle cursors are reaped on the server after 10 minutes (to prevent excess memory use). The client can only control it by setting the cursor to never timeout.

What's your use case for configuring the idle cursor timeout on the client side?

Comment by Ben McCann [ 18/Jun/14 ]

Hi, it seems I may have been conflating two issues not realizing they're separate issues. I do still care about the timeout for idle cursors as well. Is idle cursors only a client concept?

Comment by Daniel Pasette (Inactive) [ 15/Jun/14 ]

chengas123, looking for some clarification on this ticket. The 10 minute timeout you mentioned is for idle cursors, but from the context of the description, it looks like you were really interested in server side operation timeouts, as implemented in SERVER-2212 in v2.6 by $maxTimeMS. If it's the latter, I'll resolve as a duplicate of SERVER-2212.

Comment by Jeffrey Yemin [ 30/Dec/13 ]

This looks to be a duplicate of SERVER-2212.

Comment by Jeffrey Yemin [ 15/Jan/13 ]

Moved it over.

Comment by Ben McCann [ 15/Jan/13 ]

Ok, sounds like this should be filed under the core server component instead then.

Comment by Jeffrey Yemin [ 14/Jan/13 ]

This is not configurable on the server, so it would only be client-side, and it seems you can already do it by setting the socketTimeout property, e.g. https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/MongoClientOptions.java#L143

There is currently no way to configure a different timeout for different server operations. The socketTimeout applies to queries and all commands.

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