<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:54:43 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-1474] Add ability to run single operations with different timeout (e.g. Datastore.ensureIndexes())</title>
                <link>https://jira.mongodb.org/browse/JAVA-1474</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;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).&lt;/p&gt;

&lt;p&gt;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&apos;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. &lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;I can see several ways around this.&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;A workaround would be to create an additional MongoDB connection and Morphia session without timeout just to create the indexes. This is possible, but a bit cumbersome.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Better: Being able to re-configure the MongoClient object. Currently it can only return the current options (MongoClient.getMongoClientOptions()), but there&apos;s no way to set them. If this were possible we could disable the timeouts for this one operation. However it would be a bit nasty to reconfigure the Mongo client globally, affecting the entire application, while the application is running (not an issue for ensureIndexes() though).&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Best: Enable a single operation to use different timeout settings. This way the ensureIndexes() call could use different timeouts.&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;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.&lt;/p&gt;


&lt;p&gt;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.&lt;/p&gt;</description>
                <environment></environment>
        <key id="159637">JAVA-1474</key>
            <summary>Add ability to run single operations with different timeout (e.g. Datastore.ensureIndexes())</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="2">Won&apos;t Fix</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="dg@doodle.com">David Gubler</reporter>
                        <labels>
                    </labels>
                <created>Tue, 23 Sep 2014 09:23:43 +0000</created>
                <updated>Wed, 31 Jan 2018 19:40:11 +0000</updated>
                            <resolved>Wed, 31 Jan 2018 19:40:11 +0000</resolved>
                                    <version>2.11.3</version>
                                                    <component>Connection Management</component>
                                        <votes>1</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1791012" author="jeff.yemin" created="Wed, 31 Jan 2018 19:40:11 +0000"  >&lt;p&gt;I believe this has been addressed, as all relevant CRUD operation methods now take a &lt;tt&gt;maxTime&lt;/tt&gt; parameter.  See for example &lt;a href=&quot;https://github.com/jyemin/mongo-java-driver/blob/master/driver-core/src/main/com/mongodb/client/model/CreateIndexOptions.java#L51&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;CreateIndexOptions.maxTime&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While this doesn&apos;t change the per-message readSocketTimeout, it will instruct the server to give up after maxTime has been exceeded.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr94dr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>138993</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>