[JAVA-1474] Add ability to run single operations with different timeout (e.g. Datastore.ensureIndexes()) Created: 23/Sep/14 Updated: 31/Jan/18 Resolved: 31/Jan/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Connection Management |
| Affects Version/s: | 2.11.3 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | David Gubler | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Description |
|
We use Datastore.ensureIndexes(true) to let Morphia create the indexes. We also use a 30 second operation timeout (MongoOptions. socketTimeout(30000)) to make the application more robust against random problems (e.g. network issues). Now if Morphia needs to create an index on a huge collection, ensureIndexes(true) will block even though background index build is enabled, which in itself is ok, since we don't want to start the application before the indexes are ready. However, it also obeys the timeout of 30 seconds (again not a bug per se), so the operation will eventually fail. At this point the initialization of our entire application fails, because the ensureIndexes() call is part of the initialization, and we have to try to start it again, possibly several times. This is annoying. I can see several ways around this.
Apart from the Datastore.ensureIndexes() feature, the ability to run operations with different timeouts would also be useful for statistics/reporting or any sort of batch jobs. I realize that we do not run the lastest version of the driver, but I have not found any change in this area in the changelogs nor the API docs. |
| Comments |
| Comment by Jeffrey Yemin [ 31/Jan/18 ] |
|
I believe this has been addressed, as all relevant CRUD operation methods now take a maxTime parameter. See for example CreateIndexOptions.maxTime. While this doesn't change the per-message readSocketTimeout, it will instruct the server to give up after maxTime has been exceeded. |