<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:13:31 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-1885] Hinted cursors should not set slaveOk bit for primary servers</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-1885</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;From the server selection spec section on &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#read-operations&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Topology types: ReplicaSetWithPrimary or ReplicaSetNoPrimary: Read Operations&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;For all read preferences modes except &apos;primary&apos;, clients MUST set the slaveOK wire protocol flag to ensure that any suitable server can handle the request. Clients MUST NOT set the slaveOK wire protocol flag if the read preference mode is &apos;primary&apos;.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;As mentioned in the &lt;a href=&quot;https://mongodbcr.appspot.com/103230001/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;code review&lt;/a&gt; for &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1872&quot; title=&quot;mongoc_cursor_set_hint causes secondary reads in sharded cluster&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1872&quot;&gt;&lt;del&gt;CDRIVER-1872&lt;/del&gt;&lt;/a&gt;, &lt;tt&gt;mongoc_cursor_set_hint()&lt;/tt&gt; currently sets the &lt;tt&gt;slaveOK&lt;/tt&gt; bit even querying a primary, which conflicts with the spec.&lt;/p&gt;

&lt;p&gt;Fixing this means that users will now receive a &quot;not master&quot; error if libmongoc thinks the node is a primary, omits the &lt;tt&gt;slaveOk&lt;/tt&gt; bit, and the server is actually in a non-primary state. That said, how would a host transition from a primary to non-primary state without dropping its connections? Would this &quot;not master&quot; edge case even happen in practice, or is this just a theoretical?&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;As an aside, I&apos;m not familiar with the reasoning behind the spec&apos;s rule on not setting &lt;tt&gt;slaveOK&lt;/tt&gt; for primary queries. Apart from mongos, which infers a read preference behavior based on &lt;tt&gt;slaveOK&lt;/tt&gt;, the bit seems like an implementation detail. Would it be worthwhile to revise the spec to simply allow drivers to specify &lt;tt&gt;slaveOK&lt;/tt&gt; as they wish for non-mongos connections?&lt;/p&gt;</description>
                <environment></environment>
        <key id="326829">CDRIVER-1885</key>
            <summary>Hinted cursors should not set slaveOk bit for primary servers</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="jesse@mongodb.com">A. Jesse Jiryu Davis</assignee>
                                    <reporter username="jmikola@mongodb.com">Jeremy Mikola</reporter>
                        <labels>
                    </labels>
                <created>Tue, 25 Oct 2016 22:49:42 +0000</created>
                <updated>Wed, 2 Nov 2016 19:30:18 +0000</updated>
                            <resolved>Wed, 2 Nov 2016 16:34:41 +0000</resolved>
                                    <version>1.4.2</version>
                                    <fixVersion>1.5.0</fixVersion>
                                    <component>libmongoc</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1424426" author="xgen-internal-githook" created="Wed, 2 Nov 2016 19:30:18 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;ajdavis&apos;, u&apos;name&apos;: u&apos;A. Jesse Jiryu Davis&apos;, u&apos;email&apos;: u&apos;jesse@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1885&quot; title=&quot;Hinted cursors should not set slaveOk bit for primary servers&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1885&quot;&gt;&lt;del&gt;CDRIVER-1885&lt;/del&gt;&lt;/a&gt; don&apos;t send slaveok to primary after mongoc_cursor_set_hint&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/b368746aa6a64fcdc49af61e287af383c5abe31c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/b368746aa6a64fcdc49af61e287af383c5abe31c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1422207" author="jesse" created="Mon, 31 Oct 2016 19:46:44 +0000"  >&lt;p&gt;We should do this. Hannes pointed out that for PHP to conform to Server Selection Spec, cursors have to act this way.&lt;/p&gt;</comment>
                            <comment id="1417588" author="jesse" created="Tue, 25 Oct 2016 22:57:14 +0000"  >&lt;p&gt;Single threaded: Primary steps down &amp;amp; closes connections, we wait socketCheckIntervalMS (default 5 sec), we try a query. We check the socket, it&apos;s closed, we reopen and query the server we thought was primary, without noticing it&apos;s a secondary. Currently, we make sure we raise an error in this case by &lt;b&gt;not&lt;/b&gt; setting slaveOk, so the stepped-down server complains &quot;not master&quot;.&lt;/p&gt;

&lt;p&gt;Pooled: Primary steps down &amp;amp; closes connections. We create a new pooled client and open a new socket for a query. Currently, we make sure we raise an error in this case by &lt;b&gt;not&lt;/b&gt; setting slaveOk, so the stepped-down server complains &quot;not master&quot;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-562&quot; title=&quot;cluster should send newly-run ismasters through SDAM machinery&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-562&quot;&gt;&lt;del&gt;CDRIVER-562&lt;/del&gt;&lt;/a&gt; would be another way to fix both cases.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="325506">CDRIVER-1872</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <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|hsr7g7:</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>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>