<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:13:28 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-7041] DBClientCursor::init call() failed</title>
                <link>https://jira.mongodb.org/browse/SERVER-7041</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I have developed server application in C++ using the v2.2.0 c++ driver for establishing connections to MongoDb.&lt;br/&gt;
While the server is receiving the client requests, it performs MongoDb operations (connect, query, insert...). What happens is if i kill the Mongodb server (Ctrl + C) while the application server is performing MongoDb operations, in some cases i catch &quot;socket exception &lt;span class=&quot;error&quot;&gt;&amp;#91;CONNECT_ERROR&amp;#93;&lt;/span&gt; for localhost:27017&quot;, but in many cases i can not catch any exception but the server application shuts down with the message: &quot;DBClientCursor::init call() failed&quot;.&lt;br/&gt;
What is the meaning of this message, can i catch it and process it somehow, or it is a bug in the MongoDb driver?&lt;/p&gt;</description>
                <environment>O.S: Ubuntu 11.04, &lt;br/&gt;
mongodb version: Mongodb v2.2.0, &lt;br/&gt;
Hardware: Intel(R) Core(TM) i7 CPU 64bit, 8GB RAM</environment>
        <key id="50514">SERVER-7041</key>
            <summary>DBClientCursor::init call() failed</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="gregor">Gregor Macadam</assignee>
                                    <reporter username="stipsburg">Goran Nikolovski</reporter>
                        <labels>
                            <label>crash</label>
                            <label>driver</label>
                    </labels>
                <created>Fri, 14 Sep 2012 13:57:45 +0000</created>
                <updated>Wed, 3 Jul 2013 05:03:01 +0000</updated>
                            <resolved>Mon, 1 Oct 2012 13:59:47 +0000</resolved>
                                    <version>2.2.0</version>
                                                    <component>Internal Client</component>
                                        <votes>1</votes>
                                    <watches>8</watches>
                                                                                                                <comments>
                            <comment id="173048" author="ian@10gen.com" created="Tue, 9 Oct 2012 19:54:55 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=dbabits&quot; class=&quot;user-hover&quot; rel=&quot;dbabits&quot;&gt;dbabits&lt;/a&gt;, please open a new SERVER ticket with your issue so that we can track it (and tie it back to this ticket if appropriate.)&lt;/p&gt;</comment>
                            <comment id="172981" author="dbabits" created="Tue, 9 Oct 2012 17:20:05 +0000"  >&lt;p&gt;I am getting the same problem while using official mongo client:&lt;br/&gt;
Tue Oct  9 13:13:14 DBClientCursor::init call() failed&lt;br/&gt;
Tue Oct  9 13:13:14 Error: Error during mongo startup. :: caused by :: 10276 DBClientBase::findN: transport error: xxx.xxx.xxx.xxx:28017 ns: admin.$cmd query: &lt;/p&gt;
{ whatsmyuri: 1 }
&lt;p&gt; src/mongo/shell/mongo.js:93&lt;/p&gt;

&lt;p&gt;/home/hprspkg/hprs_3rd_party/mongodb-linux-x86_64-static-legacy-2.2.0/bin/mongo localhost:28017/mydb --quiet --eval &apos;db.mytable.find({id:{$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;jq_2395764120&amp;quot;,&amp;quot;jq_2395764121&amp;quot;&amp;#93;&lt;/span&gt;}}.forEach(printjson);&lt;/p&gt;

&lt;p&gt;server was shutdown prior with CTRL-C&lt;/p&gt;</comment>
                            <comment id="169758" author="gregor" created="Mon, 1 Oct 2012 13:59:38 +0000"  >&lt;p&gt;Resolving as &quot;works as designed&quot; - feel free to reopen if you don&apos;t feel this is the case. &lt;/p&gt;</comment>
                            <comment id="167020" author="renctan" created="Sat, 22 Sep 2012 13:43:51 +0000"  >&lt;p&gt;I am saying that the MongoConnection shouldn&apos;t have a ScopedDbConnection as a member variable (unless you make your class non-copyable, in fact, we should have made ScopedDbConnection non copyable). I&apos;ll show you why the current code is dangerous:&lt;/p&gt;

&lt;p&gt;MongoConnection conn;&lt;/p&gt;

&lt;p&gt;// since you are not passing by reference here, a copy is created, at this point there are 2 different objects that has a pointer to the ScopedDbConnection,&lt;br/&gt;
// hence it is being shared to more than two objects.&lt;br/&gt;
inserting(conn);&lt;/p&gt;

&lt;p&gt;Note that the copy has a scope that is only within the inserting function. So when the function terminates, it will call the MongoConnection destructor, which will in turn attempt to destruct the ScopedDbConnection (which you now placed a flag to hack around this).&lt;/p&gt;</comment>
                            <comment id="167008" author="asiljanovski" created="Sat, 22 Sep 2012 11:37:44 +0000"  >&lt;p&gt;At our project each of the server&apos;s clients (i.e. threads) get their own instance of MongoConnection. There is no double free, the problem occurs when I try to call done() and delete for specific ScopedDBConnection. If in meantime the connection to the primary node failed (primary node goes down), looks like the memory where the ScopedDBConnection pointer points gets corrupted. If you try to call done() and delete on that same pointer, the result is SIGABRT. The check that we perform for NULL in the destructor of MongoConnection was just a quick guess that we do double free. However, this did not solve the problem, adding some sort of flag that the connection to the primary node failed, did solve the problem but with possible memory leaks.&lt;/p&gt;</comment>
                            <comment id="166708" author="renctan" created="Fri, 21 Sep 2012 14:21:46 +0000"  >&lt;p&gt;I took a glance at your code and noticed that you are storing the ScopedDBConnection to the MongoConnection class. This is ok as long as you don&apos;t share the connection and don&apos;t share the pointer around (This is probably what caused the crash. ScopedDBConnection is not meant to be copied and doing a shallow copy of ScopedDBConnection can cause double free).&lt;/p&gt;</comment>
                            <comment id="166661" author="asiljanovski" created="Fri, 21 Sep 2012 11:44:08 +0000"  >&lt;p&gt;Here is a link to a simple project that we just wrote,  &lt;a href=&quot;http://dl.dropbox.com/u/15196029/MongoSample.tar.gz&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://dl.dropbox.com/u/15196029/MongoSample.tar.gz&lt;/a&gt; . It performs basically the same operations to mongodb as in our project and we managed to find the cause of the problem. &lt;br/&gt;
When the primary node goes down and DBException is thrown, the ScopedDbConnection that is being used probably gets corrupted and you can no longer call done() or its destructor. Calling it results in SIGABRT, the workaround is that we set a bool (withExc) when exception is thrown in the code, that indicates that the scoped connection failed. In this case  done() or its destructor will not be called. However I&apos;m not sure how this affects the memory i.e. if there are any leaks. My question is, is there any other way to avoid this problem other than this workaround? &lt;/p&gt;</comment>
                            <comment id="166366" author="gregor" created="Thu, 20 Sep 2012 16:13:58 +0000"  >&lt;p&gt;Is this easily reproducible for you? I&apos;ve tried to reproduce it with a small program using DBClientReplicaSet to connect to the replica set. I have three nodes with priorities 3,2,1. &lt;br/&gt;
Just to check I am doing the same thing as you here is my sequence. &lt;br/&gt;
1. I have the priority 2 and 1 node running, 2 is primary. &lt;br/&gt;
2. I bring up priority 3 node it becomes secondary.&lt;br/&gt;
3. I start my server and it connects to the replica set and begins to query in a loop. &lt;br/&gt;
4. Priority 2 node steps down and server catches DBException&apos;s while trying to access cursor. &lt;br/&gt;
5. Priority 3 node becomes primary and server can query the cursor again. &lt;/p&gt;

&lt;p&gt;I don&apos;t get a SIGABRT however. Is there some code you could attach that can reproduce this?&lt;/p&gt;</comment>
                            <comment id="165944" author="asiljanovski" created="Wed, 19 Sep 2012 11:56:52 +0000"  >&lt;p&gt;Handling the NULL cursor case seems that it has resolved the issue without replica set. &lt;br/&gt;
However, in the case of replica set with three nodes where nodes have priorities set to 3,2,1 the result is the same. Tests have shown, when all nodes are up and our server app is under load if the primary node goes down, immediately there is a message &quot;DBClientCursor::init call() failed&quot;  followed by an abort signal. Same happens when the node with priority = 3 comes back on, it tries to become primary again, thus the current primary becomes secondary but our server app is performing operations to that node, immediately the result in our application is the same.&lt;br/&gt;
In the other case where the scenario follows these steps:&lt;br/&gt;
1. our server application is down and clients try to reach to it    &lt;br/&gt;
2. the node with highest priority is down , the second highest priority node is primary&lt;br/&gt;
3. the node with highest priority comes back up&lt;br/&gt;
4. all nodes become secondary &lt;br/&gt;
5. our server goes up, still all nodes are secondary&lt;br/&gt;
6. server accepts clients and tries to perform operations in mongo , still all nodes are secondary&lt;br/&gt;
result: &lt;br/&gt;
until the highest priority node becomes primary again, during the time when all nodes are secondary, starting the server app immediately results in  &lt;br/&gt;
&quot;warning: No primary detected for set test1&quot; followed by an abort signal&lt;/p&gt;
</comment>
                            <comment id="165528" author="renctan" created="Tue, 18 Sep 2012 14:59:08 +0000"  >&lt;p&gt;DBClientCursor::init call() is a log message that appears when the driver cannot initialize the cursor. And it will make the query return a NULL DBClientCursor pointer. Does your application handle the NULL cursor case?&lt;/p&gt;</comment>
                            <comment id="165447" author="asiljanovski" created="Tue, 18 Sep 2012 11:52:00 +0000"  >&lt;p&gt;I just tried catching the signal, it resulted in SIGABRT. This situation is more likely to happen when you perform higher number of operations to mongodb i.e. when server is under load.&lt;/p&gt;</comment>
                            <comment id="165440" author="asiljanovski" created="Tue, 18 Sep 2012 11:20:57 +0000"  >&lt;p&gt;I have the same problem with the v2.2.0 C++ driver. I tested with and without replica set and got the same result. When using replica set if the primary node goes down (Ctrl + C) the application results in &quot;DBClientCursor::init call() failed&quot; and no exception can be caught in my application, looks like the driver sends some signal. &lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="20171" name="MongoSample.tar.gz" size="1323255" author="gregor" created="Fri, 21 Sep 2012 13:41:08 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>12.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 18 Sep 2012 11:20:57 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 19 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>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 19 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </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>asiljanovski</customfieldvalue>
            <customfieldvalue>dbabits</customfieldvalue>
            <customfieldvalue>stipsburg</customfieldvalue>
            <customfieldvalue>gregor</customfieldvalue>
            <customfieldvalue>ian@mongodb.com</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|hrnonz:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>16813</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|hrj15j:</customfieldvalue>

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