<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:08:46 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>[CDRIVER-210] Tailable cursor stays in PENDING condition even when connection to mongo is lost</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-210</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;I have an implementation of tailable cursors and wanted to test the behaviour of this cursor when connection to mongo was lost. My observation is that the cursor stays in the MONGO_CURSOR_PENDING state even when the connection has been lost. The conn-&amp;gt;err at this point is MONGO_IO_ERROR due to the lack of connection. &lt;/p&gt;

&lt;p&gt;Should the cursor state not be changed to MONGO_CURSOR_INVALID at this point?&lt;/p&gt;

&lt;p&gt;I took another approach as well. Since I want auto-reconnections, I added some test auto-reconnect logic at the very lower API level in the function mongo_message_send. This allows reconnection to take place without adding any wrappers to the higher level APIs. Now what happens is that the client is successfully able to reconnect. However the tailable cursor still stays in the MONGO_CURSOR_PENDING state as mentioned above. Now since mongodb has gone through a restart cycle(I am trying to mimic a recovery from a crash) it would not recognize the old cursor ID which the client is using hence it return a zero value for cursorID in the response. mongodb logs gives:&lt;/p&gt;

&lt;p&gt;Wed Apr 24 11:25:24 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn1&amp;#93;&lt;/span&gt; getMore: cursorid not found admin.configupdates 2515604382749781657&lt;/p&gt;


&lt;p&gt;This causes the following code path to be activated in the function mongo_cursor_next:&lt;/p&gt;

&lt;p&gt;if ( cursor-&amp;gt;reply-&amp;gt;fields.num == 0 ) {&lt;/p&gt;

&lt;p&gt;        /* Special case for tailable cursors. */&lt;br/&gt;
--&lt;del&gt;&amp;gt;&amp;gt;   if( cursor&lt;/del&gt;&amp;gt;reply-&amp;gt;fields.cursorID ) {&lt;br/&gt;
            if( ( mongo_cursor_get_more( cursor ) != MONGO_OK ) ||&lt;br/&gt;
                    cursor-&amp;gt;reply-&amp;gt;fields.num == 0 ) &lt;/p&gt;
{
                return MONGO_ERROR;
            }
&lt;p&gt;        }&lt;/p&gt;

&lt;p&gt;        else&lt;br/&gt;
---&amp;gt;&amp;gt;           return MONGO_ERROR;&lt;br/&gt;
    }&lt;/p&gt;

&lt;p&gt;Here the check &apos;if(cursor-&amp;gt;reply-&amp;gt;fields.cursorID)&apos; fails and MONGO_ERROR is returned without changing the state of the cursor. Shouldnt the cursor state be changed to MONGO_CURSOR_INVALID?, so that the application layer can look at this error and figure out that some kind of problem occurred and refresh its cursor. &lt;/p&gt;

&lt;p&gt;I am attaching a patch for the naive auto-reconnect that i used. Kindly comment if i should raise an issue for this or otherwise&lt;/p&gt;</description>
                <environment>Linux Fedora 2.6.35.14-97.fc14.x86_64, mongodb version 1.6.4</environment>
        <key id="72919">CDRIVER-210</key>
            <summary>Tailable cursor stays in PENDING condition even when connection to mongo is lost</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="auny">ahmed talha khan</reporter>
                        <labels>
                            <label>driver</label>
                            <label>reconnect</label>
                            <label>tailable-cursor</label>
                    </labels>
                <created>Wed, 24 Apr 2013 06:37:38 +0000</created>
                <updated>Wed, 11 Sep 2019 19:04:20 +0000</updated>
                            <resolved>Sat, 10 Aug 2013 00:35:17 +0000</resolved>
                                    <version>0.7</version>
                                    <fixVersion>0.8.1</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="399899" author="auto" created="Sat, 10 Aug 2013 00:25:02 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;gjmurakami-10gen&apos;, u&apos;name&apos;: u&apos;Gary J. Murakami&apos;, u&apos;email&apos;: u&apos;gary.murakami@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-210&quot; title=&quot;Tailable cursor stays in PENDING condition even when connection to mongo is lost&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-210&quot;&gt;&lt;del&gt;CDRIVER-210&lt;/del&gt;&lt;/a&gt; Tailable cursor set cursor invalid&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/2bed7e52d29760f62d36e8b3a395c7b6241dda96&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/2bed7e52d29760f62d36e8b3a395c7b6241dda96&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="26271" name="auto_reconnect.diff" size="6061" author="auny" created="Wed, 24 Apr 2013 06:37:38 +0000"/>
                    </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|hrngfr:</customfieldvalue>

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