<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:59:08 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-3244] Ways to timeout long mongo write operation</title>
                <link>https://jira.mongodb.org/browse/JAVA-3244</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;We are using mongo-java-driver 3.4.2, and our database structure is:&lt;/p&gt;

&lt;p&gt;sharded-cluster: # of shard: 3&lt;/p&gt;

&lt;p&gt;Have replica set every dc across&#160;US.&lt;/p&gt;

&lt;p&gt;Have 3 primarys, all the others are secondary.&lt;/p&gt;

&lt;p&gt;We now experience cross-dc network issue in one datacenter to the primary in another datacenter. So some of the requests have very long latency (16min), and succeed.&lt;/p&gt;

&lt;p&gt;Our solution is to add retry template&#160;in client side. So for the request that has a long latency, it will trigger retry and the retry one can succeed very fast. The problem is, we cannot kill the previous one (which with long latency), and eventually the mongodb&#160;execute 2 requests for it.&lt;/p&gt;

&lt;p&gt;We investigate why the long latency, and found the network from mongos to mongod&#160;has huge package loss, it may be the root cause.&lt;/p&gt;

&lt;p&gt;We wish to timeout the long latency write operation. But found mongo doc and mongo-java-driver doc, no useful timeout found.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Work we have done:&lt;/p&gt;

&lt;p&gt;From MongoClientOption: add socketTiemout, connectionTimeout, maxConnectionIdleTime, maxConnectionLifeTime. All with no use. Request can still take very long(longest is 16min)&lt;/p&gt;</description>
                <environment></environment>
        <key id="721477">JAVA-3244</key>
            <summary>Ways to timeout long mongo write operation</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="zchen12345">Zhexuan Chen</reporter>
                        <labels>
                    </labels>
                <created>Fri, 22 Mar 2019 23:10:16 +0000</created>
                <updated>Wed, 11 Sep 2019 19:14:42 +0000</updated>
                            <resolved>Tue, 2 Apr 2019 17:16:52 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="2199400" author="jeff.yemin" created="Tue, 2 Apr 2019 17:16:39 +0000"  >&lt;p&gt;For read operations, you can use &lt;a href=&quot;https://docs.mongodb.com/manual/tutorial/terminate-running-operations/index.html#maxtimems&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;maxTimeMS&lt;/a&gt; to control the execution time of the operation on the server.&lt;/p&gt;

&lt;p&gt;For write operations, the driver can be configured to [retry writes|&lt;a href=&quot;https://docs.mongodb.com/manual/core/retryable-writes/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.mongodb.com/manual/core/retryable-writes/&lt;/a&gt;]&#160;in some situations.&#160; Alternatively,&#160;&lt;a href=&quot;https://docs.mongodb.com/manual/tutorial/terminate-running-operations/index.html#killop&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;killOp&lt;/a&gt; can be used, but you&apos;ll have to handle idempotency in the application.&#160;&#160;&lt;/p&gt;</comment>
                            <comment id="2198469" author="zchen12345" created="Mon, 1 Apr 2019 21:57:55 +0000"  >&lt;p&gt;Hi Jeff.&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;They happened both read and write. And we highly doubt the root cause is the network issue, like package loss etc.&#160;&lt;/li&gt;
	&lt;li&gt;I am going to say it is not idempotent. The order of write requests getting successful in db matters. If the request takes too long, it will cause the upcoming requests be earlier than this one and cause data mismatch, so we add retry in the client.&#160;&lt;/li&gt;
&lt;/ol&gt;
</comment>
                            <comment id="2198346" author="jeff.yemin" created="Mon, 1 Apr 2019 20:50:05 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=zchen12345&quot; class=&quot;user-hover&quot; rel=&quot;zchen12345&quot;&gt;zchen12345&lt;/a&gt;.  What are the actual operations that are taking so long?  Are they read operation, write operations, or both.  If they are write operations, are the writes idempotent, in which case retrying them in the client is safe?&lt;/p&gt;
</comment>
                    </comments>
                    <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|huh6pj:</customfieldvalue>

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