<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:03 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-187] BsonBuffer waiting indefinitely on broken connection</title>
                <link>https://jira.mongodb.org/browse/CSHARP-187</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;BsonBuffer.LoadFrom contains the following loop:&lt;/p&gt;

&lt;p&gt;                while (bytesPending &amp;gt; 0) {&lt;br/&gt;
                    var bytesRead = stream.Read(localChunk, localChunkOffset, bytesPending);&lt;br/&gt;
                    if (bytesRead == 0) &lt;/p&gt;
{
                        // TODO: timeout?
                        Thread.Sleep(5); // just enough to not be busy waiting
                    }
&lt;p&gt; else &lt;/p&gt;
{
                        localChunkOffset += bytesRead;
                        bytesPending -= bytesRead;
                    }
&lt;p&gt;                }&lt;/p&gt;

&lt;p&gt;The &quot;timeout&quot; is a necessity here, since when the connection is gracefully closed from the MongoDB side (by stopping the server), the client connection remains active:&lt;br/&gt;
netstat -a -n | find &quot;:27017&quot;&lt;br/&gt;
  TCP    client:5171      mongodb:27017    CLOSE_WAIT&lt;/p&gt;

&lt;p&gt;This leads to an endless loop that just hangs the client thread when the server is gone.&lt;/p&gt;</description>
                <environment></environment>
        <key id="15400">CSHARP-187</key>
            <summary>BsonBuffer waiting indefinitely on broken connection</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="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="onyxmaster">Aristarkh Zagorodnikov</reporter>
                        <labels>
                    </labels>
                <created>Thu, 31 Mar 2011 07:52:55 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:49 +0000</updated>
                            <resolved>Fri, 1 Apr 2011 16:14:04 +0000</resolved>
                                    <version>1.0</version>
                                    <fixVersion>1.1</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="27848" author="onyxmaster" created="Tue, 5 Apr 2011 19:49:03 +0000"  >&lt;p&gt;Thanks for the fix, I&apos;ll put it through some heavy testing (multiple occasionally crashing servers in a cluster) in a few days.&lt;/p&gt;</comment>
                            <comment id="27830" author="rstam" created="Tue, 5 Apr 2011 16:14:25 +0000"  >&lt;p&gt;Pushed a new fix to this bug based on Aristarkh&apos;s research. We are now treating a return value of zero from NetworkStream.Read as end of stream with no timeout needed.&lt;/p&gt;</comment>
                            <comment id="27614" author="onyxmaster" created="Sat, 2 Apr 2011 21:15:27 +0000"  >&lt;p&gt;I checked the Mono project docs for NetworkStream.Read() also (&lt;a href=&quot;http://www.go-mono.com/docs/monodoc.ashx?link=M%3aSystem.Net.Sockets.NetworkStream.Read(System.Byte%5b%5d%2cSystem.Int32%2cSystem.Int32&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.go-mono.com/docs/monodoc.ashx?link=M%3aSystem.Net.Sockets.NetworkStream.Read(System.Byte%5b%5d%2cSystem.Int32%2cSystem.Int32&lt;/a&gt;))&lt;br/&gt;
&quot;When no incoming data is available, this method blocks and waits for data to arrive.&lt;br/&gt;
If the remote socket was shut down gracefully (Socket.Shutdown(SocketShutdown) was called on the socket or the SocketOptionName.Linger option was enabled and Socket.Close was called on the socket) and all data was received, this method immediately returns zero.&quot;&lt;/p&gt;

&lt;p&gt;So it appears that Mono handles it in the same way I described above:&lt;/p&gt;
</comment>
                            <comment id="27613" author="onyxmaster" created="Sat, 2 Apr 2011 20:59:07 +0000"  >&lt;p&gt;I did a small research and it appears that timeout might be unnecessary altogether.&lt;/p&gt;

&lt;p&gt;The documentation on NetworkStream.Read (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/xxst1299.aspx&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://msdn.microsoft.com/en-us/library/xxst1299.aspx&lt;/a&gt;) says:&lt;br/&gt;
&quot;If no data is available for reading, the Read method returns 0. The Read operation reads as much data as is available, up to the number of bytes specified by the size parameter. If the remote host shuts down the connection, and all available data has been received, the Read method completes immediately and return zero bytes.&quot;&lt;/p&gt;

&lt;p&gt;It looks like &quot;If no data is available for reading, the Read method returns 0&quot; part is plainly wrong, check this link: &lt;a href=&quot;http://social.msdn.microsoft.com/forums/en-US/netfxnetcom/thread/6dbd1467-6a90-43bb-abaa-df5ca5a1cd85&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://social.msdn.microsoft.com/forums/en-US/netfxnetcom/thread/6dbd1467-6a90-43bb-abaa-df5ca5a1cd85&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I used .NET Reflector to check out how NetworkStream.Read() is implemented:&lt;br/&gt;
public override int NetworkStream.Read(&lt;span class=&quot;error&quot;&gt;&amp;#91;In, Out&amp;#93;&lt;/span&gt; byte[] buffer, int offset, int size)&lt;br/&gt;
{&lt;br/&gt;
... various parameter checks go here, only exceptions are thrown ...&lt;br/&gt;
    try&lt;/p&gt;
    {
        num2 = streamSocket.Receive(buffer, offset, size, SocketFlags.None);
    }
&lt;p&gt;    catch (Exception exception)&lt;br/&gt;
    {&lt;br/&gt;
        if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException))&lt;/p&gt;
        {
            throw;
        }
&lt;p&gt;        throw new IOException(SR.GetString(&quot;net_io_readfailure&quot;, new object[] &lt;/p&gt;
{ exception.Message }
&lt;p&gt;), exception);&lt;br/&gt;
    }&lt;br/&gt;
    return num2;&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;So it appears that it&apos;s just a wrapper around Socket.Receive(), and its documentation (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/w3xtz6a5.aspx&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://msdn.microsoft.com/en-us/library/w3xtz6a5.aspx&lt;/a&gt;) says:&lt;br/&gt;
&quot;If you are using a connection-oriented Socket, the Receive method will read as much data as is available, up to the number of bytes specified by the size parameter. If the remote host shuts down the Socket connection with the Shutdown method, and all available data has been received, the Receive method will complete immediately and return zero bytes.&quot;&lt;br/&gt;
&quot;If no data is available for reading, the Receive method will block until data is available, unless a time-out value was set by using Socket.ReceiveTimeout. If the time-out value was exceeded, the Receive call will throw a SocketException. If you are in non-blocking mode, and there is no data available in the in the protocol stack buffer, the Receive method will complete immediately and throw a SocketException.&quot;&lt;/p&gt;

&lt;p&gt;Take note that the Socket.Receive() documentation explicitly mentions that it blocks if it can&apos;t read at least some of the data, and returns zero only if the remote end is shut down.&lt;/p&gt;

&lt;p&gt;So, it appears that there is an old, wrong text in documentation (I believe it wasn&apos;t wrong around .NET 1.1, but it changed with 2.0) and Mike Flasko (I think he was System.Net sub-library PM at that time) acknowledges that. It looks like that fix never got in for the last five years though.&lt;/p&gt;

&lt;p&gt;I agree that this might need additional testing (implementing this wrong might break existing applications completely, I volunteer to help if you need to repro something), but I think that getting immediate disconnection detection (not mentioning the warming sense of &quot;done right&quot;) would be a very good thing to have =)&lt;/p&gt;</comment>
                            <comment id="27546" author="rstam" created="Fri, 1 Apr 2011 16:14:04 +0000"  >&lt;p&gt;Fixed. Added timeout to BsonBuffer.LoadFrom.&lt;/p&gt;</comment>
                            <comment id="27541" author="onyxmaster" created="Fri, 1 Apr 2011 15:41:36 +0000"  >&lt;p&gt;Good to know you got it. I look forward to C# driver being a very robust one since I&apos;m going to put it to heavy use in the near future in an environment where server going down is a norm =)&lt;/p&gt;</comment>
                            <comment id="27540" author="rstam" created="Fri, 1 Apr 2011 15:31:04 +0000"  >&lt;p&gt;When running the server on Ubuntu I can &lt;b&gt;sometimes&lt;/b&gt; reproduce this. Depends on the exact moment that the server is killed.&lt;/p&gt;

&lt;p&gt;1. If the server is killed and the next operation on the client is SendMessage an exception is thrown&lt;br/&gt;
2. If the server is killed after the client calls SendMessage and before it calls ReceiveMessage the client hangs&lt;/p&gt;

&lt;p&gt;So I guess the timeout is necessary after all. Will put it in.&lt;/p&gt;

&lt;p&gt;Thanks for reporting this!&lt;/p&gt;</comment>
                            <comment id="27535" author="rstam" created="Fri, 1 Apr 2011 14:42:41 +0000"  >&lt;p&gt;When I attempt to reproduce this I always get an IOException instead of a hung client.&lt;/p&gt;

&lt;p&gt;The only difference is that I am running the server on another Windows machine, not Ubuntu. Will setup an Ubuntu environment to test with.&lt;/p&gt;

&lt;p&gt;Unhandled exception:&lt;br/&gt;
System.IO.IOException: Unable to write data to the transport connection: An exis&lt;br/&gt;
ting connection was forcibly closed by the remote host. ---&amp;gt; System.Net.Sockets.&lt;br/&gt;
SocketException: An existing connection was forcibly closed by the remote host&lt;br/&gt;
   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, So&lt;br/&gt;
cketFlags socketFlags)&lt;br/&gt;
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32&lt;br/&gt;
size)&lt;br/&gt;
   &amp;#8212; End of inner exception stack trace &amp;#8212;&lt;br/&gt;
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32&lt;br/&gt;
size)&lt;br/&gt;
   at MongoDB.Bson.IO.BsonBuffer.WriteTo(Stream stream) in C:\work\10gen\mongodb&lt;br/&gt;
\mongo-csharp-driver\Bson\IO\BsonBuffer.cs:line 761&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage me&lt;br/&gt;
ssage, SafeMode safeMode) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\In&lt;br/&gt;
ternal\MongoConnection.cs:line 381&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoCursorEnumerator`1.GetReply(MongoRequestMessa&lt;br/&gt;
ge message) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoCu&lt;br/&gt;
rsorEnumerator.cs:line 201&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoCursorEnumerator`1.GetMore() in C:\work\10gen&lt;br/&gt;
\mongodb\mongo-csharp-driver\Driver\Internal\MongoCursorEnumerator.cs:line 194&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoCursorEnumerator`1.MoveNext() in C:\work\10ge&lt;br/&gt;
n\mongodb\mongo-csharp-driver\Driver\Internal\MongoCursorEnumerator.cs:line 103&lt;br/&gt;
   at TestBrokenConnection.Program.Main(String[] args) in c:\users\robert stam\d&lt;br/&gt;
ocuments\visual studio 2010\Projects\TestBrokenConnection\TestBrokenConnection\P&lt;br/&gt;
rogram.cs:line 37&lt;br/&gt;
Press Enter to continue&lt;/p&gt;</comment>
                            <comment id="27482" author="onyxmaster" created="Thu, 31 Mar 2011 21:26:09 +0000"  >&lt;p&gt;Here I allow one test to finish and then stop the database when the 2nd test is in progress.&lt;br/&gt;
Sorry for the wall of text, but I think this might be helpful &amp;#8211; it&apos;s an extract of the log:&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; MongoDB starting : pid=2013 port=27017 dbpath=/data/mongodb 64-bit&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; db version v1.8.0, pdfile version 4.5&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; git version: 9c28b1d608df0ed6ebe791f63682370082da41c0&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; build sys info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; journal dir=/data/mongodb/journal&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; recover : no journal files present, no recovery needed&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; waiting for connections on port 27017&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;websvr&amp;#93;&lt;/span&gt; web admin interface listening on port 28017&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 127.0.0.1:55279 #1&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 192.168.7.243:38367 #2&lt;br/&gt;
^^^^ self (celestine-3)&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;startReplSets&amp;#93;&lt;/span&gt; replSet STARTUP2&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;rs Manager&amp;#93;&lt;/span&gt; replSet can&apos;t see a majority, will not try to elect self&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;ReplSetHealthPollTask&amp;#93;&lt;/span&gt; replSet info celestine-2 is up&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;ReplSetHealthPollTask&amp;#93;&lt;/span&gt; replSet member celestine-2 SECONDARY&lt;br/&gt;
Thu Mar 31 12:07:32 &lt;span class=&quot;error&quot;&gt;&amp;#91;replica set sync&amp;#93;&lt;/span&gt; replSet SECONDARY&lt;br/&gt;
Thu Mar 31 12:07:33 &lt;span class=&quot;error&quot;&gt;&amp;#91;rs Manager&amp;#93;&lt;/span&gt; replSet info electSelf 3&lt;br/&gt;
Thu Mar 31 12:07:33 &lt;span class=&quot;error&quot;&gt;&amp;#91;MultiCommandJob&amp;#93;&lt;/span&gt; DBClientCursor::init call() failed&lt;br/&gt;
Thu Mar 31 12:07:33 &lt;span class=&quot;error&quot;&gt;&amp;#91;rs Manager&amp;#93;&lt;/span&gt; replSet couldn&apos;t elect self, only received -9999 votes&lt;br/&gt;
Thu Mar 31 12:07:34 &lt;span class=&quot;error&quot;&gt;&amp;#91;ReplSetHealthPollTask&amp;#93;&lt;/span&gt; replSet info celestine-1 is up&lt;br/&gt;
Thu Mar 31 12:07:34 &lt;span class=&quot;error&quot;&gt;&amp;#91;ReplSetHealthPollTask&amp;#93;&lt;/span&gt; replSet member celestine-1 SECONDARY&lt;br/&gt;
Thu Mar 31 12:07:35 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 192.168.7.242:47302 #3&lt;br/&gt;
^^^^ replication partner (celestine-2)&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:35 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 192.168.7.241:55912 #4&lt;br/&gt;
^^^^ replication partner (celestine-1)&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:35 &lt;span class=&quot;error&quot;&gt;&amp;#91;rs Manager&amp;#93;&lt;/span&gt; replSet info electSelf 3&lt;br/&gt;
Thu Mar 31 12:07:35 &lt;span class=&quot;error&quot;&gt;&amp;#91;rs Manager&amp;#93;&lt;/span&gt; replSet PRIMARY&lt;br/&gt;
Thu Mar 31 12:07:37 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 192.168.7.241:55914 #5&lt;br/&gt;
^^^^ replication partner (celestine-1)&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:43 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 192.168.7.44:5395 #6&lt;br/&gt;
^^^^ client connected&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:43 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn6&amp;#93;&lt;/span&gt; getmore test1.items cid:2776051345393985494 getMore: {}  bytes:4194290 nreturned:144630 130ms&lt;br/&gt;
^^^^ cursor continuation&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:44 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 192.168.7.242:47303 #7&lt;br/&gt;
^^^^ replication partner (celestine-2)&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:46 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn6&amp;#93;&lt;/span&gt; getmore test1.items cid:2776051345393985494 getMore: {}  bytes:3976616 nreturned:137124 129ms&lt;br/&gt;
^^^^ cursor continuation&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:50 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn6&amp;#93;&lt;/span&gt; end connection 192.168.7.44:5395&lt;br/&gt;
^^^^ client disconnected&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:51 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 192.168.7.44:5396 #8&lt;br/&gt;
^^^^ client connected&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:52 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn8&amp;#93;&lt;/span&gt; getmore test1.items cid:5322570835678218172 getMore: {}  bytes:4194290 nreturned:144630 109ms&lt;br/&gt;
^^^^ cursor continuation&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:53 got kill or ctrl c or hup signal 15 (Terminated), will terminate after current cmd ends&lt;br/&gt;
^^^ got SIGHUP&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; now exiting&lt;br/&gt;
Thu Mar 31 12:07:53 dbexit:&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: going to close listening sockets...&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; closing listening socket: 6&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; closing listening socket: 7&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; closing listening socket: 8&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; closing listening socket: 9&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; removing socket file: /tmp/mongodb-27017.sock&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; removing socket file: /tmp/mongodb-28017.sock&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: going to flush diaglog...&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: going to close sockets...&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: waiting for fs preallocator...&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: lock for final commit...&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: final commit...&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: closing all files...&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn2&amp;#93;&lt;/span&gt; end connection 192.168.7.243:38367&lt;br/&gt;
^^^^ self (celestine-3)&lt;/p&gt;

&lt;p&gt;Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn1&amp;#93;&lt;/span&gt; end connection 127.0.0.1:55279&lt;br/&gt;
Thu Mar 31 12:07:53 closeAllFiles() finished&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: journalCleanup...&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; removeJournalFiles&lt;br/&gt;
Thu Mar 31 12:07:53 &lt;span class=&quot;error&quot;&gt;&amp;#91;interruptThread&amp;#93;&lt;/span&gt; shutdown: removing fs lock...&lt;br/&gt;
Thu Mar 31 12:07:53 dbexit: really exiting now&lt;/p&gt;</comment>
                            <comment id="27479" author="onyxmaster" created="Thu, 31 Mar 2011 21:21:13 +0000"  >&lt;p&gt;Nope, I used graceful stop using the script that comes with the Ubuntu package: sudo service stop mongodb&lt;br/&gt;
I think the script just sends a SIGHUP to the MongoDB process.&lt;/p&gt;</comment>
                            <comment id="27477" author="rstam" created="Thu, 31 Mar 2011 21:18:21 +0000"  >&lt;p&gt;OK. So looks like part of the key to reproducing is to make sure the &quot;items&quot; collection has enough items in it that this loop take many seconds to execute, giving time for you to stop the server.&lt;/p&gt;

&lt;p&gt;How are you stopping the server? CTL-C?&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;</comment>
                            <comment id="27472" author="onyxmaster" created="Thu, 31 Mar 2011 21:12:48 +0000"  >&lt;p&gt;I still use the same test code as before:&lt;br/&gt;
        static void ReadTest() &lt;br/&gt;
        { &lt;br/&gt;
            try &lt;/p&gt;
            { 
                const string connectionString = &quot;mongodb://celestine-3/test1?slaveOk=true&quot;; 
                var database = MongoDatabase.Create(MongoUrl.Create(connectionString)); 
                var items = database[&quot;items&quot;]; 
                var cursor = items.FindAll(); 
                long sum = 0; 
                foreach (var item in cursor) 
                    sum += item[&quot;v&quot;].ToInt64(); 
            } 
&lt;p&gt;            catch (Exception ex) &lt;/p&gt;
            { 
                Console.WriteLine(ex.ToString()); 
            } 
&lt;p&gt;            Console.ReadKey(); &lt;br/&gt;
        } &lt;/p&gt;

&lt;p&gt;celestine-3 is running Linux x86-64 (Ubuntu 10.04), with mongodb 1.8.0 release (binary from 10gen ubuntu repo) as a primary (doesn&apos;t matter, secondaries fail in the same way, I guess that non-replicated machines would do the same) member of a 3-member replica set.&lt;br/&gt;
The client is running Windows 7 x64 SP1, .NET 4.0, build is done under VS 2010 SP1.&lt;br/&gt;
The &quot;test1&quot; database contains &quot;items&quot; collection which has several hundred thousand items like {_id: ObjectId, v: some_number}.&lt;br/&gt;
I run the ReadTest() method, wait about 3 seconds, then stop the mongodb service on celestine-3. I check the process to be stopped, it&apos;s gone, but the connection hangs in the &quot;CLOSE_WAIT&quot; state indefinitely and stream.Read() just returns zero. I left the client machine in this state for about half an hour &amp;#8211; when I returned the client was still looping.&lt;/p&gt;</comment>
                            <comment id="27427" author="rstam" created="Thu, 31 Mar 2011 15:03:13 +0000"  >&lt;p&gt;Is there an easy way to reproduce this?&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|hrh96v:</customfieldvalue>

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