<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:09:12 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>[SERVER-5541] crash in C++ client driver during shutdowing primary mongo server from repset</title>
                <link>https://jira.mongodb.org/browse/SERVER-5541</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I was  testing stability of my client which used mongo server and client was crashed in mongo C++ client driver at moment of shutdowing primary mongo server.&lt;br/&gt;
This crash is reproduced every time. See guide below&lt;/p&gt;

&lt;p&gt;Here is stack trace of crash:&lt;br/&gt;
#0  0x0830d98d in mongo::DBClientCursor::peekError(mongo::BSONObj*) ()&lt;br/&gt;
#1  0x08313f6b in mongo::DBClientReplicaSet::checkSlaveQueryResult(std::auto_ptr&amp;lt;mongo::DBClientCursor&amp;gt;) ()&lt;br/&gt;
#2  0x08313a3c in mongo::DBClientReplicaSet::query(std::basic_string&amp;lt;char, std::char_traits&amp;lt;char&amp;gt;, std::allocator&amp;lt;char&amp;gt; &amp;gt; const&amp;amp;, mongo::Query, int, int, mongo::BSONObj const*, int, int) ()&lt;/p&gt;


&lt;p&gt;Guide to reproduce this:&lt;/p&gt;

&lt;p&gt;Make replicaSet configuration like this:&lt;br/&gt;
PRIMARY&amp;gt; rs.conf()&lt;br/&gt;
{&lt;br/&gt;
        &quot;_id&quot; : &quot;wop_test&quot;,&lt;br/&gt;
        &quot;version&quot; : 15,&lt;br/&gt;
        &quot;members&quot; : [&lt;br/&gt;
                &lt;/p&gt;
{
                        &quot;_id&quot; : 0,
                        &quot;host&quot; : &quot;10.68.11.136:27017&quot;,
                        &quot;priority&quot; : 26
                }
&lt;p&gt;,&lt;br/&gt;
                &lt;/p&gt;
{
                        &quot;_id&quot; : 1,
                        &quot;host&quot; : &quot;10.68.11.138:27017&quot;,
                        &quot;votes&quot; : 0,
                        &quot;priority&quot; : 0
                }
&lt;p&gt;,&lt;/p&gt;
                {
                        &quot;_id&quot; : 2,
                        &quot;host&quot; : &quot;10.68.11.138:27018&quot;,
                        &quot;votes&quot; : 0,
                        &quot;priority&quot; : 0
                }
&lt;p&gt;        ]&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;Shutdown server #1 and #2 (which have no votes)&lt;/p&gt;

&lt;p&gt;Then shutdown last standing primary #0 and immediately make request from client.&lt;br/&gt;
If request will be doing a few seconds after shutdowning #0, client will be handle it correct (throw exception)&lt;/p&gt;


&lt;p&gt;May be it because I use old C++ client 2.0.2-pre with server 2.0.4 ?&lt;/p&gt;
</description>
                <environment>CentOS 6&lt;br/&gt;
server 2.0.4&lt;br/&gt;
C++ client 2.0.2-pre</environment>
        <key id="35703">SERVER-5541</key>
            <summary>crash in C++ client driver during shutdowing primary mongo server from repset</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="randolph@mongodb.com">Randolph Tan</assignee>
                                    <reporter username="magum">Alexander Borodetsky</reporter>
                        <labels>
                    </labels>
                <created>Sat, 7 Apr 2012 17:54:07 +0000</created>
                <updated>Mon, 11 Jul 2016 18:35:27 +0000</updated>
                            <resolved>Wed, 11 Apr 2012 16:00:19 +0000</resolved>
                                    <version>2.0.2</version>
                    <version>2.0.4</version>
                                    <fixVersion>2.0.5</fixVersion>
                    <fixVersion>2.1.1</fixVersion>
                                    <component>Internal Client</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="110778" author="auto" created="Tue, 17 Apr 2012 18:25:59 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;&apos;, u&apos;name&apos;: u&apos;Randolph Tan&apos;, u&apos;email&apos;: u&apos;randolph@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5541&quot; title=&quot;crash in C++ client driver during shutdowing primary mongo server from repset&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5541&quot;&gt;&lt;del&gt;SERVER-5541&lt;/del&gt;&lt;/a&gt; crash in C++ client driver during shutdowing primary mongo server from repset&lt;br/&gt;
Branch: v2.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/d87357cf26a75dca02407f03326876e1d1803369&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/d87357cf26a75dca02407f03326876e1d1803369&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="110769" author="renctan" created="Tue, 17 Apr 2012 18:10:47 +0000"  >&lt;p&gt;You&apos;re welcome.&lt;/p&gt;</comment>
                            <comment id="110495" author="magum" created="Tue, 17 Apr 2012 00:38:21 +0000"  >&lt;p&gt;Thanx a lot for your fix and assistance.&lt;br/&gt;
It works properly now&lt;/p&gt;</comment>
                            <comment id="108705" author="renctan" created="Wed, 11 Apr 2012 14:42:04 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;The new commit now returns whatever the query method returns you, for consistency. So your client code should be prepared to handle null pointers as you would when using DBCLientConnection.&lt;/p&gt;</comment>
                            <comment id="108702" author="auto" created="Wed, 11 Apr 2012 14:28:00 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;&apos;, u&apos;name&apos;: u&apos;Randolph Tan&apos;, u&apos;email&apos;: u&apos;randolph@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5541&quot; title=&quot;crash in C++ client driver during shutdowing primary mongo server from repset&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5541&quot;&gt;&lt;del&gt;SERVER-5541&lt;/del&gt;&lt;/a&gt; crash in C++ client driver during shutdowing primary mongo server from repset&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/ab60e77554527f22626d050fe6b01ee44fb55e01&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/ab60e77554527f22626d050fe6b01ee44fb55e01&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="108080" author="magum" created="Mon, 9 Apr 2012 23:52:36 +0000"  >&lt;p&gt;assert didn&apos;t solve this issue properly. This fix leads to calling abort() on windows or raise(SIGTRAP) on linux for debug build. And my server abnormally stops.&lt;br/&gt;
To resolve it I try to put &lt;br/&gt;
      if ( !result.get() ) throw AssertionException (&quot;no slaves due no cursor&quot;,0);&lt;br/&gt;
instead assert( result.get() );&lt;/p&gt;

&lt;p&gt;But it lead to returning NULL cursor from DBClientReplicaSet::query without throwing any exception. It happens because checkMaster()&amp;#45;&amp;gt;query() is called after three attempts of calling checkSlaveQueryResult(). And so checkMaster()&amp;#45;&amp;gt;query() return NULL cursor too.&lt;/p&gt;

&lt;p&gt;So my question is: Is it correct that DBClientReplicaSet::query return NULL cursor?&lt;br/&gt;
As I understand by investigating src code it is correct and I have to handle NULL cursor. Am I right?&lt;/p&gt;
</comment>
                            <comment id="107712" author="auto" created="Mon, 9 Apr 2012 03:40:14 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;erh&apos;, u&apos;name&apos;: u&apos;Eliot Horowitz&apos;, u&apos;email&apos;: u&apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: assert that we have a cursor rather than segv &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5541&quot; title=&quot;crash in C++ client driver during shutdowing primary mongo server from repset&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5541&quot;&gt;&lt;del&gt;SERVER-5541&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/ea6fb0bcc1233b8439e57225df3d4b088e019662&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/ea6fb0bcc1233b8439e57225df3d4b088e019662&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="107674" author="eliot" created="Sun, 8 Apr 2012 13:53:32 +0000"  >&lt;p&gt;pushed a possible fix to 2.0&lt;br/&gt;
can you either try from git or with tomorrows build&lt;/p&gt;</comment>
                            <comment id="107673" author="auto" created="Sun, 8 Apr 2012 13:51:08 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;erh&apos;, u&apos;name&apos;: u&apos;Eliot Horowitz&apos;, u&apos;email&apos;: u&apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: assert that we have a cursor rather than segv &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5541&quot; title=&quot;crash in C++ client driver during shutdowing primary mongo server from repset&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5541&quot;&gt;&lt;del&gt;SERVER-5541&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: v2.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/dbf67c31dc46b0f5bac2ed8827be2f3cb39a2dda&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/dbf67c31dc46b0f5bac2ed8827be2f3cb39a2dda&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="107632" author="magum" created="Sat, 7 Apr 2012 21:03:22 +0000"  >&lt;p&gt;The crash caused by following:&lt;br/&gt;
I have caught it on Windows in debugger )&lt;/p&gt;

&lt;p&gt;DBClientReplicaSet::checkSlaveQueryResult( auto_ptr&amp;lt;DBClientCursor&amp;gt; result ) is calling with NULL value of argument &quot;result&quot;&lt;br/&gt;
It happens because its caller DBClientReplicaSet::query calls checkSlave()-&amp;gt;query(...) which return nothing.&lt;/p&gt;

&lt;p&gt;Here is call stack:&lt;br/&gt;
 	char-srv-dbg.exe!std::_Debug_message(const wchar_t * message=0x0099f480, const wchar_t * file=0x00995860, unsigned int line=742)  Line 24	C++&lt;br/&gt;
 	char-srv-dbg.exe!std::auto_ptr&amp;lt;mongo::DBClientCursor&amp;gt;::operator-&amp;gt;()  Line 742 + 0x14 bytes	C++&lt;br/&gt;
 	char-srv-dbg.exe!mongo::DBClientReplicaSet::checkSlaveQueryResult(std::auto_ptr&amp;lt;mongo::DBClientCursor&amp;gt; result=auto_ptr {b=&lt;/p&gt;
{...} _client=??? ns={...}
&lt;p&gt; ...})  Line 798 + 0xc bytes	C++&lt;br/&gt;
&amp;gt;	char-srv-dbg.exe!mongo::DBClientReplicaSet::query(const std::basic_string&amp;lt;char,std::char_traits&amp;lt;char&amp;gt;,std::allocator&amp;lt;char&amp;gt; &amp;gt; &amp;amp; ns=&quot;wop_rel.log&quot;, mongo::Query query=&lt;/p&gt;
{...}
&lt;p&gt;, int nToReturn=150, int nToSkip=0, const mongo::BSONObj * fieldsToReturn=0x00000000, int queryOptions=4, int batchSize=0)  Line 753 + 0xa6 bytes	C++&lt;/p&gt;
</comment>
                            <comment id="107623" author="magum" created="Sat, 7 Apr 2012 18:55:23 +0000"  >&lt;p&gt;Any other gdb command return &quot;no debug info&quot; error&lt;/p&gt;</comment>
                            <comment id="107622" author="magum" created="Sat, 7 Apr 2012 18:54:19 +0000"  >&lt;p&gt;Unfortunately I have some troubles with symbol on my building system.&lt;/p&gt;

&lt;p&gt;So I have only backtarce (in main description) and this info:&lt;/p&gt;

&lt;p&gt;(gdb) info frame&lt;br/&gt;
Stack level 0, frame at 0xdfdea980:&lt;br/&gt;
 eip = 0x830eb3d in mongo::DBClientCursor::peekError(mongo::BSONObj*); saved eip 0x8315f79&lt;br/&gt;
 called by frame at 0xdfdea9e0&lt;br/&gt;
 source language c++.&lt;br/&gt;
 Arglist at 0xdfdea978, args:&lt;br/&gt;
 Locals at 0xdfdea978, Previous frame&apos;s sp is 0xdfdea980&lt;br/&gt;
 Saved registers:&lt;br/&gt;
  ebp at 0xdfdea978, eip at 0xdfdea97c&lt;/p&gt;

&lt;p&gt;Maybe you have any ideas about gdb?&lt;/p&gt;


</comment>
                            <comment id="107618" author="magum" created="Sat, 7 Apr 2012 18:36:39 +0000"  >&lt;p&gt;Yes. I try doing it now. Wait a minute. I have no symbols on my test station. I need to transfer core-dump to build station.&lt;/p&gt;</comment>
                            <comment id="107617" author="eliot" created="Sat, 7 Apr 2012 18:31:48 +0000"  >&lt;p&gt;Can you run in gdb so you can get line number of seg fault?&lt;/p&gt;</comment>
                            <comment id="107616" author="magum" created="Sat, 7 Apr 2012 18:31:07 +0000"  >&lt;p&gt;I&apos;m catching exception. But only std::exception, not SIGSEGV ))&lt;/p&gt;</comment>
                            <comment id="107615" author="magum" created="Sat, 7 Apr 2012 18:29:39 +0000"  >&lt;p&gt;Program received signal SIGSEGV, Segmentation fault.&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;Switching to Thread 0xe25efb70 (LWP 17542)&amp;#93;&lt;/span&gt;&lt;br/&gt;
0x0830eb3d in mongo::DBClientCursor::peekError(mongo::BSONObj*) ()&lt;/p&gt;

&lt;p&gt;But if I wait a few second before doing request, client handle it (shutdowning server) with exception (I suppose it is correct behaviour ) )&lt;/p&gt;</comment>
                            <comment id="107614" author="eliot" created="Sat, 7 Apr 2012 18:25:29 +0000"  >&lt;p&gt;Was it a crash or just an exception being thrown?&lt;br/&gt;
Are you catching exceptions?&lt;/p&gt;</comment>
                            <comment id="107613" author="magum" created="Sat, 7 Apr 2012 18:22:32 +0000"  >&lt;p&gt;I have got C++ client driver 2.0.4 source code and rebuild my solution ( client from point of view of mongodb ) with it.&lt;br/&gt;
Client still crashed at such place&lt;/p&gt;</comment>
                            <comment id="107602" author="magum" created="Sat, 7 Apr 2012 18:00:45 +0000"  >&lt;p&gt;Note. It&apos;s important to make request immediately after shutdowning server. Otherwise (if you are late) shutdown of last server will be handled by client with correct exception&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>19.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sat, 7 Apr 2012 18:25:29 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 44 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 44 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10020"><![CDATA[Linux]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>magum</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>randolph@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hro6n3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrgbqn:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>8811</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hriz5b:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>