<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:45 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>[CSHARP-412] SlaveOk queries directed to RECOVERING instances</title>
                <link>https://jira.mongodb.org/browse/CSHARP-412</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;When one of our secondaries is resynced, it appears that C# driver sends slaveOk queries to it while it&apos;s still recovering.&lt;br/&gt;
There are several errors in the database log like this one:&lt;br/&gt;
Mon Mar 19 21:21:03 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn328&amp;#93;&lt;/span&gt; assertion 13436 not master or secondary, can&apos;t read ns:d2_feed3.counters.car&lt;br/&gt;
And, of course, the query fails on the client side.&lt;/p&gt;</description>
                <environment></environment>
        <key id="33291">CSHARP-412</key>
            <summary>SlaveOk queries directed to RECOVERING instances</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="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="onyxmaster">Aristarkh Zagorodnikov</reporter>
                        <labels>
                    </labels>
                <created>Mon, 19 Mar 2012 17:24:10 +0000</created>
                <updated>Thu, 2 Apr 2015 18:28:26 +0000</updated>
                            <resolved>Tue, 20 Mar 2012 15:18:00 +0000</resolved>
                                    <version>1.3.1</version>
                                    <fixVersion>1.4</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="100557" author="onyxmaster" created="Tue, 20 Mar 2012 14:13:00 +0000"  >&lt;p&gt;Good to know that you found out the reason, looking forward for the fix =)&lt;/p&gt;</comment>
                            <comment id="100550" author="rstam" created="Tue, 20 Mar 2012 13:57:25 +0000"  >&lt;p&gt;Thanks so much for repeating the test and providing the additional information. It is very useful.&lt;/p&gt;

&lt;p&gt;In the reply to isMaster we see:&lt;/p&gt;

&lt;p&gt;{&lt;br/&gt;
    isMaster : false,&lt;br/&gt;
    secondary : false&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;which we expect, because even though the new member is a secondary the server has been coded to return &lt;/p&gt;
{ secondary : false }
&lt;p&gt; when a secondary is in recovering mode.&lt;/p&gt;

&lt;p&gt;So normally the C# driver would not have sent queries to this secondary until it was done with the initial sync, at which point the server would start returning &lt;/p&gt;
{ secondary : true }
&lt;p&gt;.&lt;/p&gt;

&lt;p&gt;But what&apos;s different in this scenario is that this secondary has also been configured as a passive secondary, which we can see from the &lt;/p&gt;
{ passive : true }
&lt;p&gt; in the response to isMaster.&lt;/p&gt;

&lt;p&gt;All drivers consider passive secondaries as eligible to receive slaveOk queries, so my theory is that the C# driver is sending queries to this secondary not because of &lt;/p&gt;
{ secondary : true }
&lt;p&gt;, but because of &lt;/p&gt;
{ passive : true }
&lt;p&gt;.&lt;/p&gt;

&lt;p&gt;I&apos;ve experimented with a local replica set and it looks like isMaster returns &lt;/p&gt;
{ secondary : true }
&lt;p&gt; even for passive members (but not until they are out of recovery mode), so it looks like all we need to do is remove the check for IsPassive from the driver when it is choosing which secondary to send a slaveOk query to, since passives will already be eligible due to &lt;/p&gt;
{ secondary : true }
&lt;p&gt;.&lt;/p&gt;

&lt;p&gt;I will try and find out if in earlier versions of the server it was returning &lt;/p&gt;
{ secondary : false }
&lt;p&gt; for passives, but I suspect it was not and that it was just an invalid assumption on my part that the algorithm that distributes slaveOk queries to secondaries had to check the IsPassive flag also.&lt;/p&gt;</comment>
                            <comment id="100461" author="onyxmaster" created="Tue, 20 Mar 2012 08:16:40 +0000"  >&lt;p&gt;It appears that it&apos;s related to cursors:&lt;br/&gt;
MongoDB.Driver.MongoQueryException: QueryFailure flag was not master or secondary, can&apos;t read (response was &lt;/p&gt;
{ &quot;$err&quot; : &quot;not master or secondary, can&apos;t read&quot;, &quot;code&quot; : 13436 }
&lt;p&gt;).&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(BsonBuffer buffer, IBsonSerializationOptions serializationOptions) in Driver\Internal\MongoReplyMessage.cs:line 102&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage&lt;span class=&quot;error&quot;&gt;&amp;#91;TDocument&amp;#93;&lt;/span&gt;(BsonBinaryReaderSettings readerSettings, IBsonSerializationOptions serializationOptions) in Driver\Internal\MongoConnection.cs:line 435&lt;br/&gt;
   at MongoDB.Driver.MongoCursorEnumerator`1.GetReply(MongoConnection connection, MongoRequestMessage message) in Driver\Core\MongoCursorEnumerator.cs:line 296&lt;br/&gt;
   at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() in Driver\Core\MongoCursorEnumerator.cs:line 253&lt;br/&gt;
   at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() in Driver\Core\MongoCursorEnumerator.cs:line 141&lt;br/&gt;
   at System.Linq.Enumerable.ToDictionary&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource,TKey,TElement&amp;#93;&lt;/span&gt;(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)&lt;/p&gt;
</comment>
                            <comment id="100459" author="onyxmaster" created="Tue, 20 Mar 2012 08:13:18 +0000"  >&lt;p&gt;Yes, it repeats.&lt;br/&gt;
isMaster returns the following:&lt;br/&gt;
{&lt;br/&gt;
        &quot;setName&quot; : &quot;drive2&quot;,&lt;br/&gt;
        &quot;ismaster&quot; : false,&lt;br/&gt;
        &quot;secondary&quot; : false,&lt;br/&gt;
        &quot;hosts&quot; : [&lt;br/&gt;
                &quot;l1-1.sheratan.bru:27017&quot;&lt;br/&gt;
        ],&lt;br/&gt;
        &quot;passives&quot; : [&lt;br/&gt;
                &quot;l1-1.shaula.bru:27017&quot;&lt;br/&gt;
        ],&lt;br/&gt;
        &quot;arbiters&quot; : [&lt;br/&gt;
                &quot;l1-1.perseus.bru:27017&quot;&lt;br/&gt;
        ],&lt;br/&gt;
        &quot;primary&quot; : &quot;l1-1.sheratan.bru:27017&quot;,&lt;br/&gt;
        &quot;passive&quot; : true,&lt;br/&gt;
        &quot;me&quot; : &quot;l1-1.shaula.bru:27017&quot;,&lt;br/&gt;
        &quot;maxBsonObjectSize&quot; : 16777216,&lt;br/&gt;
        &quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;
</comment>
                            <comment id="100337" author="rstam" created="Mon, 19 Mar 2012 20:39:44 +0000"  >&lt;p&gt;Is this a test that you can repeat? I&apos;m curious to know what that replica set member was sending back in response to the isMaster command during the time is was doing the initial sync. It looks like it must have been sending back &lt;/p&gt;
{ secondary: true }
&lt;p&gt; the whole time it was doing the initial sync. If that&apos;s the case this might be considered a server bug.&lt;/p&gt;

&lt;p&gt;Alternatively, the driver could follow up the isMaster command with a second call to replSetGetStatus (which is the only way to get the actual status of the replica set member), which would be somewhat detrimental in that it&apos;s a second network round trip (but it does only happen once every 10 seconds).&lt;/p&gt;

&lt;p&gt;I grepped the other drivers and none of them are calling replSetGetStatus.&lt;/p&gt;</comment>
                            <comment id="100280" author="onyxmaster" created="Mon, 19 Mar 2012 19:08:12 +0000"  >&lt;p&gt;I&apos;ll give you an extract of the log to give you proper impressions of timings.&lt;br/&gt;
\e start empty replica slave:&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; MongoDB starting : pid=13154 port=27017 dbpath=/mnt/disk3/mongodb 64-bit host=shaula&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; db version v2.0.2, pdfile version 4.5&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; git version: 514b122d308928517f5841888ceaa4246a7f18e3&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; build info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; options: &lt;/p&gt;
{ bind_ip: &quot;l1-1.shaula.bru,c1.shaula.bru,127.0.0.1&quot;, config: &quot;/etc/mongodb.conf&quot;, dbpath: &quot;/mnt/disk3/mongodb&quot;, directoryperdb: &quot;true&quot;, logappend: &quot;true&quot;, logpath: &quot;/var/log/mongodb/mongodb.log&quot;, noauth: &quot;true&quot;, noprealloc: &quot;true&quot;, replSet: &quot;drive2&quot;, rest: &quot;true&quot;, slowms: 500, smallfiles: &quot;true&quot; }
&lt;p&gt;Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; journal dir=/mnt/disk3/mongodb/journal&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; recover : no journal files present, no recovery needed&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; preallocateIsFaster=true 2.22&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; couldn&apos;t connect to localhost:27017: couldn&apos;t connect to server localhost:27017&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; replSet can&apos;t get local.system.replset config from self or any seed (EMPTYCONFIG)&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; replSet info you may need to run replSetInitiate &amp;#8211; rs.initiate() in the shell &amp;#8211; if that is not already done&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;websvr&amp;#93;&lt;/span&gt; admin web console waiting for connections on port 28017&lt;br/&gt;
Mon Mar 19 21:17:45 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; waiting for connections on port 27017&lt;br/&gt;
...&lt;br/&gt;
It finds replication partners:&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; trying to contact l1-1.perseus.bru:27017&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; trying to contact l1-1.sheratan.bru:27017&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; replSet got config version 7 from a remote, saving locally&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; replSet info saving a newer config version to local.system.replset&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;FileAllocator&amp;#93;&lt;/span&gt; allocating new datafile /mnt/disk3/mongodb/local/local.ns, filling with zeroes...&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;FileAllocator&amp;#93;&lt;/span&gt; done allocating datafile /mnt/disk3/mongodb/local/local.ns, size: 16MB,  took 0.001 secs&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;FileAllocator&amp;#93;&lt;/span&gt; allocating new datafile /mnt/disk3/mongodb/local/local.0, filling with zeroes...&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;FileAllocator&amp;#93;&lt;/span&gt; done allocating datafile /mnt/disk3/mongodb/local/local.0, size: 16MB,  took 0.001 secs&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; replSet saveConfigLocally done&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsStart&amp;#93;&lt;/span&gt; replSet STARTUP2&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsSync&amp;#93;&lt;/span&gt; ******&lt;br/&gt;
Mon Mar 19 21:17:55 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsSync&amp;#93;&lt;/span&gt; creating replication oplog of size: 2943MB...&lt;br/&gt;
...&lt;br/&gt;
We start receiving these:&lt;br/&gt;
Mon Mar 19 21:17:57 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn4&amp;#93;&lt;/span&gt; assertion 13436 not master or secondary, can&apos;t read ns:d2_feed3.counters.car query:&lt;/p&gt;
{ _id: -3735451117392232444 }
&lt;p&gt;...&lt;br/&gt;
This is the last one (15 minutes after the first one, 1037 &quot;assert 13436&quot; lines later)&lt;br/&gt;
Mon Mar 19 21:33:37 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn2085&amp;#93;&lt;/span&gt; assertion 13436 not master or secondary, can&apos;t read ns:d2_visits.guests query:{ $query: { _id.u: 288&lt;br/&gt;
230376151887937, t: &lt;/p&gt;
{ $gte: new Date(1329508800000) }
&lt;p&gt; }, $orderby: &lt;/p&gt;
{ t: -1 }
&lt;p&gt; }&lt;br/&gt;
...&lt;br/&gt;
Initial sync completed:&lt;br/&gt;
Mon Mar 19 21:35:03 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsSync&amp;#93;&lt;/span&gt; replSet initial sync done&lt;br/&gt;
Mon Mar 19 21:35:04 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 10.1.1.21:54748 #2166&lt;br/&gt;
Mon Mar 19 21:35:04 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsSync&amp;#93;&lt;/span&gt; replSet syncing to: l1-1.sheratan.bru:27017&lt;br/&gt;
Mon Mar 19 21:35:04 &lt;span class=&quot;error&quot;&gt;&amp;#91;rsSync&amp;#93;&lt;/span&gt; replSet SECONDARY&lt;/p&gt;</comment>
                            <comment id="100256" author="rstam" created="Mon, 19 Mar 2012 18:50:59 +0000"  >&lt;p&gt;When a secondary is in recovering state it should be report &lt;/p&gt;
{ secondary: false }
&lt;p&gt; in the response to isMaster (see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-3459&quot; title=&quot;isMaster reports secondary == false when a node is recovering&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-3459&quot;&gt;&lt;del&gt;SERVER-3459&lt;/del&gt;&lt;/a&gt;), which is what keeps the driver from sending queries to secondaries in recovering mode.&lt;/p&gt;

&lt;p&gt;Is this just a timing issue? The members of the replica set are polled once every 10 seconds, so it might take the driver a few seconds to detect that a secondary has gone into recovering mode.&lt;/p&gt;

&lt;p&gt;Would that explain what you are seeing?&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|hrh7vr:</customfieldvalue>

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