<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:43:13 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-2679] Connection aborted in MongoDB</title>
                <link>https://jira.mongodb.org/browse/CSHARP-2679</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;We are working on automatic upgrade tool to migrate data from Mongo 2.4 to Mongo 4.0 and we are using &lt;b&gt;Mongo driver version 2.8.1 with &#160;.net core version 2.1.&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;During the upgrade process We are connecting via Mongo client to &#160;Mongo Server 2.4, then shutting &#160;down the service ,upgrading &#160;the Mongo version &#160;to 2.6 &#160;starting it and then stopping it upgrading to 3.0 and etc.&lt;/p&gt;

&lt;p&gt;During this process We have a problem of disconnection of the mongo driver as result of shutting down the Mongo services which seems to stuck the Mongo driver and every command we are trying to execute for example ListDatabases from our mongo client gets the following exception:&lt;/p&gt;

&lt;p&gt;System.AggregateException: One or more errors occurred. (An exception occurred while receiving a message from the server.) ---&amp;gt; MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server. ---&amp;gt; System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---&amp;gt; System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine&lt;/p&gt;

&lt;p&gt;&#160;&#160; &amp;#8212; End of inner exception stack trace &amp;#8212;&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()&lt;/p&gt;

&lt;p&gt;&#160;&#160; &amp;#8212; End of inner exception stack trace &amp;#8212;&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(Int32 responseTo, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageAsync(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocolAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(IWireProtocol`1 protocol, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocolAsync(IChannelSource channelSource, ICoreSessionHandle session, ReadPreference readPreference, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.MongoDatabaseImpl.ExecuteReadOperationAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;(IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at MongoDB.Driver.MongoDatabaseImpl.UsingImplicitSessionAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(Func`2 funcAsync, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; &amp;#8212; End of inner exception stack trace &amp;#8212;&lt;/p&gt;

&lt;p&gt;&#160;&#160; at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)&lt;/p&gt;

&lt;p&gt;&#160;&#160; at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout)&lt;/p&gt;

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

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

&lt;p&gt;Thank you.&lt;/p&gt;

&lt;p&gt;Daniel.&lt;/p&gt;</description>
                <environment></environment>
        <key id="884861">CSHARP-2679</key>
            <summary>Connection aborted in MongoDB</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="13202">Works as Designed</resolution>
                                        <assignee username="vincent.kam@mongodb.com">Vincent Kam</assignee>
                                    <reporter username="danielfr@riscogroup.com">daniel friedmann</reporter>
                        <labels>
                    </labels>
                <created>Tue, 6 Aug 2019 07:08:38 +0000</created>
                <updated>Fri, 27 Oct 2023 13:24:55 +0000</updated>
                            <resolved>Mon, 26 Aug 2019 15:06:05 +0000</resolved>
                                    <version>2.8.1</version>
                                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="2386672" author="vincent.kam" created="Mon, 26 Aug 2019 15:05:46 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=danielfr%40riscogroup.com&quot; class=&quot;user-hover&quot; rel=&quot;danielfr@riscogroup.com&quot;&gt;danielfr@riscogroup.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thank you for filing a JIRA ticket! A socket exception is expected when shutting down your `mongod` instances: using driver version 2.9.1 may also help due to the addition of the retryable reads feature, which is enabled by default.&lt;/p&gt;

&lt;p&gt;Kind regards,&lt;br/&gt;
Vincent&lt;/p&gt;</comment>
                            <comment id="2385504" author="danielfr@riscogroup.com" created="Sun, 25 Aug 2019 10:07:12 +0000"  >&lt;p&gt;Hey all.&lt;/p&gt;

&lt;p&gt;We solve the issue with a workaround.&lt;/p&gt;

&lt;p&gt;we set the MaxConnectionIdleTime property to 500 milliseconds and it force the driver to reconnect.&lt;/p&gt;</comment>
                            <comment id="2373264" author="danielfr@riscogroup.com" created="Thu, 15 Aug 2019 11:57:38 +0000"  >&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;After every 2 upgrades we get the listDatabases exception,&#160; and It happens for the first time after we restore the db.&lt;/p&gt;

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

&lt;p&gt;Below you can find the function that we are using which the line that gets the exception (marked in red).&lt;/p&gt;

&lt;p&gt;After trying debug the mongo driver we see that the socket is not available. we saw the issue is in class BinaryConnection line 314:&lt;/p&gt;

&lt;p&gt;_stream.ReadBytes(messageSizeBytes, 0, 4, _backgroundTaskCancellationToken);&lt;/p&gt;

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

&lt;p&gt;&#160;&#160;&#160;&#160;&#160; &#160;public bool MongoDump(string arguments, string exportPath)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/p&gt;
{

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var finalArgument = $&quot;\{GetLocalMongoShellAuthenticationArgument()}
&lt;p&gt; {arguments} --out {exportPath}&quot;;&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _log.Info($&quot;Performing MongoDump with arguments {arguments}&quot;);&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (var process = CreateMongoProcess(MongoConstants.MongoDumpFileName, finalArgument))&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/p&gt;
{

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; process.Start();

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; process.WaitForExit();

&#160;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return process.ExitCode == 0;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}&lt;br/&gt;
&lt;br/&gt;
&#160;&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; public bool MongoRestore(bool isLocalRestore, bool authenticationRequired, string arguments, string importPath)&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; {&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; string finalArgument;&lt;br/&gt;
&lt;br/&gt;
&#160;&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (isLocalRestore)&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var authentication = authenticationRequired ? GetLocalMongoShellAuthenticationArgument() : string.Empty;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; finalArgument = $&quot;\{authentication} {arguments} {importPath}&quot;;&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var authentication = authenticationRequired ? GetRemoteMongoShellAuthenticationArgument() : string.Empty;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; finalArgument = $&quot;\{authentication} {importPath}&quot;;&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&lt;br/&gt;
&lt;br/&gt;
&#160;&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _log.Info($&quot;Performing MongoRestore with arguments {arguments}&quot;);&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (var process = CreateMongoProcess(MongoConstants.MongoRestoreFileName, finalArgument))&lt;br/&gt;
&lt;br/&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; process.Start();

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; process.WaitForExit();

&#160;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return process.ExitCode == 0;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }

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

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

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

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

&lt;p&gt;var mongoClient = new MongoClient(mongoCredentials);&lt;/p&gt;

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

&lt;p&gt;&lt;b&gt;&lt;font color=&quot;#de350b&quot;&gt;using (var databaseCursor = mongoClient.ListDatabases())&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;

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

&lt;p&gt;&#160;&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|hv80yf:</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>