Can we set the mongoDB cursor timeout to a particular value instead of default 30000 ms ?
Asked
Active
Viewed 7,580 times
0
-
`com.mongodb.client.FindIterable#noCursorTimeout(true)` – Michael Pacheco Aug 14 '19 at 15:49
1 Answers
2
As far as I know it's still impossible, at least with default Java driver. There is a feature request demanding the same thing, but it's still not implemented. It seems, though, that server itself already supports query timeouts, so we can expect the driver to support them too sooner or later.
Meanwhile you have one more solution to try here. TImeout can be completely disabled with the following option:
cursor.addOption(com.mongodb.Bytes.QUERYOPTION_NOTIMEOUT)

Jk1
- 11,233
- 9
- 54
- 64
-
Jusr a quick note that the query timeout and cursor timeout are not the same thing. See https://jira.mongodb.org/browse/SERVER-8188 for the configurable cursor timeouts. – Rob Moore Dec 31 '13 at 14:13
-
As per [SERVER-2112](https://jira.mongodb.org/browse/SERVER-2212) which you linked, the server query timeout (`$maxTimeMS`) was only recently added. The "fixVersion" is noted as the 2.5.4 unstable/development release, which means this feature is targeted for the eventual MongoDB 2.6 production release. – Stennie Jan 05 '14 at 06:52
-
I'm getting this exception even after the query is not ideal. http://stackoverflow.com/questions/29624575/mongo-cursornotfound-exception-in-active-cursor-via-grails-domain-criteria – Shashank Agrawal Apr 14 '15 at 12:47