<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:39:56 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>[CSHARP-1547] Transient error handling</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1547</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;We have a web application that queries a MongoDB database and as we have thousands of documents we paginate on MongoDB (I tell this but I do not think it matters) and if we do not interact with the web application for some minutes, then, when we start again the first request it fails (it is probably a timeout) and the MongoDB Driver throws this exception:&lt;br/&gt;
Type: MongoConnectionException, &lt;br/&gt;
StackTrace: at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute(Expression expression)&lt;br/&gt;
at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(Expression expression)&lt;br/&gt;
at System.Linq.Queryable.Count&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IQueryable`1 source)&lt;/p&gt;

&lt;p&gt;Next requests go okay.&lt;/p&gt;

&lt;p&gt;So far, we have wrapped all requests to MongoDB with Func&amp;lt;T&amp;gt; and Actions so we perform a simple retry strategy but this has some problems:&lt;br/&gt;
  1) We have to wrap all MongoDB calls within Func&amp;lt;T&amp;gt; so there is high probability that we miss some statements&lt;br/&gt;
  2) The retry works fine but the Exception is not thrown right away. It is thrown like 30-45 seconds after the request are sent.&lt;/p&gt;

&lt;p&gt;So we would like to have some mechanism to handle these situations centrally (for example, in Entity Framework you can inject the transient error handling strategy by means of subclasses).&lt;/p&gt;</description>
                <environment>- Server side: a virtual machine hosted in Microsoft Azure running Ubuntu-14_04-LTS and MongoDB 3.2.1&lt;br/&gt;
&lt;br/&gt;
- Client side: A cloud service hosted in Microsoft Azure running Windows 2012 R2 and making calls to MongoDB using the .NET driver (2.1.0).&lt;br/&gt;
</environment>
        <key id="261291">CSHARP-1547</key>
            <summary>Transient error handling</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="suikevil">Roberto P&#233;rez</reporter>
                        <labels>
                    </labels>
                <created>Wed, 27 Jan 2016 22:00:59 +0000</created>
                <updated>Wed, 9 Mar 2016 21:31:05 +0000</updated>
                            <resolved>Wed, 9 Mar 2016 21:31:05 +0000</resolved>
                                    <version>2.1</version>
                                                    <component>Connectivity</component>
                    <component>Error Handling</component>
                                        <votes>1</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1160993" author="suikevil" created="Tue, 2 Feb 2016 15:16:16 +0000"  >&lt;p&gt;Okay, thanks Craig.&lt;/p&gt;

&lt;p&gt;Let&apos;s close this ticket and wait for updates in #1343 ticket.&lt;/p&gt;

&lt;p&gt;Regards&lt;/p&gt;</comment>
                            <comment id="1160866" author="craiggwilson" created="Tue, 2 Feb 2016 13:59:34 +0000"  >&lt;p&gt;If you&apos;d like, you can file a separate feature request ticket for that. We have been discussing what is even possible internally between the drivers and have not come up with a good solution yet. We are thinking about it though.&lt;/p&gt;

&lt;p&gt;UPDATE: In fact, here is the ticket about a retry policy: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-1343&quot; title=&quot;Ability to set a retry policy&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-1343&quot;&gt;&lt;del&gt;CSHARP-1343&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                            <comment id="1160827" author="suikevil" created="Tue, 2 Feb 2016 13:00:01 +0000"  >&lt;p&gt;Hello Craig again,&lt;/p&gt;

&lt;p&gt;You really made my day ^^&lt;br/&gt;
I have repeated the steps and when setting maxIdleTime to 3 minutes, it works as expected.&lt;br/&gt;
mongoClientSettings.MaxConnectionIdleTime = new TimeSpan(0, 3, 0);&lt;/p&gt;

&lt;p&gt;However if I set it to 3 minutes and 59 seconds, it keeps failing. 3 minutes it is a good value for us, anyway.&lt;/p&gt;

&lt;p&gt;Now that we have got around the problem, should we care about transient errors or does the driver manage them and retries those requests?&lt;/p&gt;

&lt;p&gt;Thank you so much,&lt;/p&gt;
</comment>
                            <comment id="1160703" author="craiggwilson" created="Tue, 2 Feb 2016 10:32:07 +0000"  >&lt;p&gt;Great.&lt;/p&gt;

&lt;p&gt;Azure has an appliance with a relatively low setting for killing off idle connections. In your connection string, you can set the maxIdleTime to be something under 4 minutes. This will tell the driver that if a connection has been idle for however long your setting is, then it will close the connection create a new one. This is ideal for your situation where your application may be idle for a period of time.&lt;/p&gt;

&lt;p&gt;This setting is also controllable in azure and can be configured for up to 30 minutes. Between the driver and Azure, you can tweak these numbers to get the best performance.&lt;/p&gt;

&lt;p&gt;Let me know if this works,&lt;br/&gt;
Craig&lt;/p&gt;</comment>
                            <comment id="1160697" author="suikevil" created="Tue, 2 Feb 2016 10:23:04 +0000"  >&lt;p&gt;Hi Craig,&lt;/p&gt;

&lt;p&gt;Thank you for you reply. Yes, everything is on Azure.&lt;/p&gt;

&lt;p&gt;You can find the environment description in the Details --&amp;gt; Environment section.&lt;/p&gt;

&lt;p&gt;Regards!&lt;/p&gt;</comment>
                            <comment id="1160692" author="craiggwilson" created="Tue, 2 Feb 2016 10:11:52 +0000"  >&lt;p&gt;Hi Roberto,&lt;/p&gt;

&lt;p&gt;I have seen this behavior before. It has to do with idle connections that are closed by an external server or appliance. Could you provide some details on the environment you are running in? For instance, are your servers and/or client in Azure or AWS?&lt;/p&gt;

&lt;p&gt;Craig&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|hshsjj:</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>