<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 22:00:36 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>[CXX-866] It will raise runtime error at finish of program when using mongocxx::options::find.limit()</title>
                <link>https://jira.mongodb.org/browse/CXX-866</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;       mongocxx::collection collection = conn&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;wechat&amp;quot;&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;article&amp;quot;&amp;#93;&lt;/span&gt;;&lt;br/&gt;
       bsoncxx::builder::stream::document condition, options;&lt;br/&gt;
       mongocxx::options::find opts;&lt;/p&gt;

&lt;p&gt;       condition &amp;lt;&amp;lt; &quot;subscribeRobot&quot; &amp;lt;&amp;lt; open_document &amp;lt;&amp;lt; &quot;$exists&quot; &amp;lt;&amp;lt; 1 &amp;lt;&amp;lt; close_document;&lt;br/&gt;
        options &amp;lt;&amp;lt; &quot;subscribeRobot&quot; &amp;lt;&amp;lt; 1;&lt;br/&gt;
        opts.projection(options.view());&lt;br/&gt;
        opts.limit(100);&lt;/p&gt;

&lt;p&gt;mongocxx::cursor cur = collection.find(condition.view(), opts);&lt;br/&gt;
        for(auto &amp;amp;&amp;amp; doc:cur)&lt;/p&gt;
{
            cout &amp;lt;&amp;lt; bsoncxx::to_json(doc) &amp;lt;&amp;lt; endl;}</description>
                <environment>Ubuntu15.4 Clang3.6.0</environment>
        <key id="272476">CXX-866</key>
            <summary>It will raise runtime error at finish of program when using mongocxx::options::find.limit()</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="4">Incomplete</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="LeoZhao">zy1989 [X]</reporter>
                        <labels>
                    </labels>
                <created>Tue, 15 Mar 2016 01:53:00 +0000</created>
                <updated>Wed, 11 Sep 2019 19:04:46 +0000</updated>
                            <resolved>Wed, 23 Mar 2016 15:24:13 +0000</resolved>
                                    <version>3.0.0</version>
                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1212559" author="leozhao" created="Wed, 23 Mar 2016 15:48:17 +0000"  >&lt;p&gt;Sorry for relying late, Matt. This error doesn&apos;t cause by code pasted here.&lt;br/&gt;
It happens when I try to use&lt;br/&gt;
           int n = 10; // this is in range.&lt;br/&gt;
           *next(cur.begin(), n)&lt;br/&gt;
I have avoid this usage and the error never happen again.&lt;br/&gt;
Thanks for all your help.&lt;/p&gt;</comment>
                            <comment id="1212514" author="matt.cotter" created="Wed, 23 Mar 2016 15:24:13 +0000"  >&lt;p&gt;Hello!&lt;/p&gt;

&lt;p&gt;It&apos;s been a while with no news; I&apos;m closing this for now.&lt;br/&gt;
Please reopen is you still need assistance with this.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;br/&gt;
-Matt&lt;/p&gt;</comment>
                            <comment id="1206049" author="matt.cotter" created="Wed, 16 Mar 2016 22:08:47 +0000"  >&lt;p&gt;New update! The official word is that &lt;/p&gt;
{mongoc_cursor_next}
&lt;p&gt; is supposed to work as we expect.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=LeoZhao&quot; class=&quot;user-hover&quot; rel=&quot;LeoZhao&quot;&gt;LeoZhao&lt;/a&gt; - can you consistently reproduce this? If so, would you mind posting a dump of the data that you use to reproduce this?&lt;/p&gt;

&lt;p&gt;Thanks again!&lt;br/&gt;
-Matt&lt;/p&gt;</comment>
                            <comment id="1206028" author="matt.cotter" created="Wed, 16 Mar 2016 21:48:25 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=acm&quot; class=&quot;user-hover&quot; rel=&quot;acm&quot;&gt;acm&lt;/a&gt; - I&apos;m still looking into how this can happen, but the advice from &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=bjori&quot; class=&quot;user-hover&quot; rel=&quot;bjori&quot;&gt;bjori&lt;/a&gt; is reflected in &lt;a href=&quot;https://github.com/mongodb/mongo-cxx-driver/pull/465&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this PR&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=LeoZhao&quot; class=&quot;user-hover&quot; rel=&quot;LeoZhao&quot;&gt;LeoZhao&lt;/a&gt; - can you try the branch in the PR and see if it fixes your issue? Thanks again for reporting this &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; &lt;/p&gt;</comment>
                            <comment id="1205165" author="acm" created="Wed, 16 Mar 2016 13:03:43 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=matt.cotter&quot; class=&quot;user-hover&quot; rel=&quot;matt.cotter&quot;&gt;matt.cotter&lt;/a&gt; -&lt;/p&gt;

&lt;p&gt;Under what circumstances does mongoc_collection_find fail to return a cursor? I think that should inform our decision. If the case where it does not return a cursor really represents an error (one for which we can ask the underlying C driver what went wrong), I would lean towards an exception.&lt;/p&gt;</comment>
                            <comment id="1204310" author="matt.cotter" created="Tue, 15 Mar 2016 19:09:51 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=LeoZhao&quot; class=&quot;user-hover&quot; rel=&quot;LeoZhao&quot;&gt;LeoZhao&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;&lt;del&gt;Does this print anything at all? I&apos;m suspecting that the cursor failed from the very beginning.&lt;/del&gt;&lt;br/&gt;
edit: ^ never mind, the original description said this was not the case.&lt;/p&gt;

&lt;p&gt;It looks like libmongoc&apos;s mongoc_collection_find can return a failed cursor, but we don&apos;t check for that in mongocxx collection find, nor do we offer a way to test this in the cursor class itself. &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=acm&quot; class=&quot;user-hover&quot; rel=&quot;acm&quot;&gt;acm&lt;/a&gt; - I&apos;m thinking that we should do one of&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;throw in find if the cursor fails&lt;/li&gt;
	&lt;li&gt;return an optional cursor from find&lt;/li&gt;
	&lt;li&gt;add an is_failed() or something similar to mongocxx::cursor&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;thoughts?&lt;/p&gt;</comment>
                            <comment id="1203305" author="leozhao" created="Tue, 15 Mar 2016 01:55:03 +0000"  >&lt;p&gt;Following error will be throwed in the print of last document.&lt;br/&gt;
         terminate called after throwing an instance of &apos;mongocxx::v_noabi::query_exception&apos;&lt;br/&gt;
         what():  Cannot advance a completed or failed cursor.: generic server error&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|hsjezr:</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>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="941">Platforms 12 (04/01/16)</customfieldvalue>

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