<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51: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>[JAVA-147] Automatically routing of queries to non-master nodes (if slave_ok set)</title>
                <link>https://jira.mongodb.org/browse/JAVA-147</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Add support to control how operations are handled when slave_ok is used. Extend the connection to include two pools of ports; one for the master node and one for non-master nodes. Create a configuration option to allow using non-master nodes for non-write operations (queries basically).&lt;/p&gt;

&lt;p&gt;Maybe something like this:&lt;/p&gt;

&lt;p&gt;class QueryOptions {&lt;br/&gt;
   boolean masterOnly = true;&lt;br/&gt;
   String[] excludedReplicas = null;&lt;br/&gt;
   String[] includedReplicas = null;&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;By setting excluded/includedReplicas you can filter certain replicas in/out of the pools. By default the master will be only server used; this keeps compatibility with the existing driver.&lt;/p&gt;</description>
                <environment></environment>
        <key id="12702">JAVA-147</key>
            <summary>Automatically routing of queries to non-master nodes (if slave_ok set)</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="scotthernandez">Scott Hernandez</reporter>
                        <labels>
                    </labels>
                <created>Sat, 7 Aug 2010 02:53:40 +0000</created>
                <updated>Fri, 29 Oct 2010 02:49:59 +0000</updated>
                            <resolved>Sun, 3 Oct 2010 22:20:37 +0000</resolved>
                                                    <fixVersion>2.2</fixVersion>
                                                        <votes>10</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="19049" author="josephykwang" created="Sun, 10 Oct 2010 01:44:11 +0000"  >&lt;p&gt;All java files were given to Alvin as part of contract negotiation. I&apos;ll ping Alvin to forward you the program.&lt;/p&gt;</comment>
                            <comment id="19048" author="eliot" created="Sun, 10 Oct 2010 01:39:12 +0000"  >&lt;p&gt;Can you provide a full test that shows that&lt;/p&gt;</comment>
                            <comment id="19047" author="josephykwang" created="Sun, 10 Oct 2010 01:28:26 +0000"  >&lt;p&gt;Tested Java 2.2 driver on a replication set.&lt;/p&gt;

&lt;p&gt;config = {_id: &apos;lp&apos;, members: [&lt;br/&gt;
                          {_id: 0, host: &apos;ip-10-166-57-74:10000&apos;},&lt;br/&gt;
                          {_id: 1, host: &apos;ip-10-166-59-166:10000&apos;},&lt;br/&gt;
                          {_id: 2, host: &apos;ip-10-166-59-166:10001&apos;, arbiterOnly: true}]&lt;br/&gt;
           }&lt;br/&gt;
rs.initiate(config);&lt;/p&gt;


&lt;p&gt;&amp;gt; rs.status()&lt;br/&gt;
{&lt;br/&gt;
        &quot;set&quot; : &quot;lp&quot;,&lt;br/&gt;
        &quot;date&quot; : &quot;Sat Oct 09 2010 16:01:36 GMT-0400 (EDT)&quot;,&lt;br/&gt;
        &quot;myState&quot; : 1,&lt;br/&gt;
        &quot;members&quot; : [&lt;br/&gt;
                &lt;/p&gt;
{
                        &quot;_id&quot; : 0,
                        &quot;name&quot; : &quot;ip-10-166-57-74:10000&quot;,
                        &quot;health&quot; : 1,
                        &quot;state&quot; : 1,
                        &quot;self&quot; : true
                }
&lt;p&gt;,&lt;br/&gt;
                &lt;/p&gt;
{
                        &quot;_id&quot; : 1,
                        &quot;name&quot; : &quot;ip-10-166-59-166:10000&quot;,
                        &quot;health&quot; : 1,
                        &quot;state&quot; : 2,
                        &quot;uptime&quot; : 1265,
                        &quot;lastHeartbeat&quot; : &quot;Sat Oct 09 2010 16:01:34 GMT-0400 (EDT)&quot;
                }
&lt;p&gt;,&lt;/p&gt;
                {
                        &quot;_id&quot; : 2,
                        &quot;name&quot; : &quot;ip-10-166-59-166:10001&quot;,
                        &quot;health&quot; : 1,
                        &quot;state&quot; : 7,
                        &quot;uptime&quot; : 1265,
                        &quot;lastHeartbeat&quot; : &quot;Sat Oct 09 2010 16:01:34 GMT-0400 (EDT)&quot;
                }
&lt;p&gt;        ],&lt;br/&gt;
        &quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;All queried fields are indexed.&lt;br/&gt;
&amp;gt; db.lp.mrtest.stats()&lt;br/&gt;
{&lt;br/&gt;
        &quot;ns&quot; : &quot;lp.lp.mrtest&quot;,&lt;br/&gt;
        &quot;count&quot; : 10000000,&lt;br/&gt;
        &quot;size&quot; : 960000064,&lt;br/&gt;
        &quot;avgObjSize&quot; : 96.0000064,&lt;br/&gt;
        &quot;storageSize&quot; : 1300797440,&lt;br/&gt;
        &quot;numExtents&quot; : 24,&lt;br/&gt;
        &quot;nindexes&quot; : 3,&lt;br/&gt;
        &quot;lastExtentSize&quot; : 223323136,&lt;br/&gt;
        &quot;paddingFactor&quot; : 1,&lt;br/&gt;
        &quot;flags&quot; : 1,&lt;br/&gt;
        &quot;totalIndexSize&quot; : 2325859136,&lt;br/&gt;
        &quot;indexSizes&quot; : &lt;/p&gt;
{
                &quot;_id_&quot; : 591102912,
                &quot;ver_1_mr_1_lt_1_lp_1_pt_1&quot; : 735855552,
                &quot;ver_1_mr_1_lt_1_lp_1_id_1_bbi_1_ir_1_pt_1&quot; : 998900672
        }
&lt;p&gt;,&lt;br/&gt;
        &quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;It seems the query performance degrades significantly (w/ or w/o addOption).&lt;/p&gt;</comment>
                            <comment id="19025" author="scotthernandez" created="Sat, 9 Oct 2010 00:03:07 +0000"  >&lt;p&gt;Yes, and Mongo/DB/DBCollection all have a slaveOk() method to enable this by default for queries down the line.&lt;/p&gt;</comment>
                            <comment id="19024" author="josephykwang" created="Fri, 8 Oct 2010 23:17:32 +0000"  >&lt;p&gt;To test this, we simply do coll.find(query).addOption(Bytes.QUERYOPTION_SLAVEOK)? It will auto route to slaves if it is a query and to master if it is a write/update.&lt;/p&gt;</comment>
                            <comment id="18977" author="eliot" created="Thu, 7 Oct 2010 18:02:23 +0000"  >&lt;p&gt;Right now only from priority 1.&lt;br/&gt;
That&apos;s mostly because priorities &amp;gt; 0 &amp;amp;&amp;amp; &amp;lt; 1 aren&apos;t implemented fully yet.&lt;br/&gt;
Once that happens - will probably change driver.&lt;/p&gt;</comment>
                            <comment id="18976" author="jeff_y" created="Thu, 7 Oct 2010 17:42:00 +0000"  >&lt;p&gt;Eliot, did you mean that driver will only read from slaves with priority &amp;gt;= 1, and not from slaves with priority &amp;lt; 1, or did you mean that driver will only read from slaves with priority &amp;gt; 0 and not from slaves with priority = 0?&lt;/p&gt;</comment>
                            <comment id="18834" author="auto" created="Sun, 3 Oct 2010 22:20:38 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;erh&apos;, &apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: add a pair test for changes for &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-147&quot; title=&quot;Automatically routing of queries to non-master nodes (if slave_ok set)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-147&quot;&gt;&lt;del&gt;JAVA-147&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/commit/05463b4bc61f2147a41c706db8274373ff80eb56&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/commit/05463b4bc61f2147a41c706db8274373ff80eb56&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="18833" author="eliot" created="Sun, 3 Oct 2010 22:20:37 +0000"  >&lt;p&gt;Testers would be greatly appreciated.&lt;/p&gt;</comment>
                            <comment id="18830" author="eliot" created="Sun, 3 Oct 2010 17:22:20 +0000"  >&lt;p&gt;This should be working now using master.&lt;br/&gt;
Testers would be greatly appreciated.&lt;/p&gt;</comment>
                            <comment id="18829" author="auto" created="Sun, 3 Oct 2010 17:22:06 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;erh&apos;, &apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: when using replica set and setting SLAVE_OK automatically route reads to slaves &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-147&quot; title=&quot;Automatically routing of queries to non-master nodes (if slave_ok set)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-147&quot;&gt;&lt;del&gt;JAVA-147&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/commit/6dcd6a6d69844f590f61c48badd9b278551d4850&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/commit/6dcd6a6d69844f590f61c48badd9b278551d4850&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="18828" author="jeff_y" created="Sun, 3 Oct 2010 17:20:38 +0000"  >&lt;p&gt;Perfect.&lt;/p&gt;</comment>
                            <comment id="18826" author="eliot" created="Sun, 3 Oct 2010 16:51:55 +0000"  >&lt;p&gt;Not in the way the description says.&lt;/p&gt;

&lt;p&gt;Though this will only read from priority 1 slaves, so if you make your backup slaves priority 0, then you&apos;ll be in good shape.&lt;/p&gt;
</comment>
                            <comment id="18825" author="jeff_y" created="Sun, 3 Oct 2010 16:44:23 +0000"  >&lt;p&gt;Are you still planning on adding support for excluded replicas?  The use case I&apos;m thinking of is that we have a replica set where one or more nodes are being used solely for backups (and therefore might be shut down every 15 minutes to take an FS snapshot), perhaps in combination with --slavedelay, but the rest of the slaves should be used to take read load off the master.  Also, one of the slaves might be in a different data center, so we don&apos;t want to read from that one either.&lt;/p&gt;</comment>
                            <comment id="18822" author="eliot" created="Sun, 3 Oct 2010 16:16:56 +0000"  >&lt;p&gt;I think its ok for a slave ok to go to a salve in a request block.&lt;br/&gt;
you still are at some point saying &quot;go to slave&quot; so should be expected.&lt;/p&gt;</comment>
                            <comment id="18821" author="auto" created="Sun, 3 Oct 2010 16:16:37 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;erh&apos;, &apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: plugging in ReplicaSetStatus to DBTCPConnector final prep for &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-147&quot; title=&quot;Automatically routing of queries to non-master nodes (if slave_ok set)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-147&quot;&gt;&lt;del&gt;JAVA-147&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/commit/465528d0f4620af275f500ed596f5df74e29e614&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/commit/465528d0f4620af275f500ed596f5df74e29e614&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="18820" author="jeff_y" created="Sun, 3 Oct 2010 15:19:59 +0000"  >&lt;p&gt;For our use cases, we would not be mixing write and reads, but we might have multiple reads that we want to go to the same slave.  So we definitely want the ability for query in the middle of requestStart/requestDone block to be routed to a slave.   What if there was some way to indicate on the requestStart method what the intention is: reads only, writes only, or mixed reads and writes.  The first would go to a slave, and the second and third to the master (so reads are consistent with previous writes).&lt;/p&gt;</comment>
                            <comment id="18819" author="josephykwang" created="Sun, 3 Oct 2010 14:47:43 +0000"  >&lt;p&gt;If it is a write/update operation, then it should use the master. In this way, we&apos;ve write-to-master &amp;amp; read-from-slave concept apply to all situation. &lt;br/&gt;
1) It makes it easier to debug write/update issue.  Otherwise, it will create a situation that different data are sitting in different machines.&lt;br/&gt;
2)  I&apos;ll assume it makes data replication logic more closely align with existing system.&lt;/p&gt;</comment>
                            <comment id="18818" author="eliot" created="Sun, 3 Oct 2010 11:29:31 +0000"  >&lt;p&gt;Question:   If you are in the middle of a requestStart/requestDone block, and you do a query with SLAVE_OK, should it use the master or a slave.&lt;/p&gt;

&lt;p&gt;Any thoughts?&lt;/p&gt;</comment>
                            <comment id="17526" author="josephykwang" created="Sat, 28 Aug 2010 19:32:47 +0000"  >&lt;p&gt;Same issue was opened  in &lt;a href=&quot;http://jira.mongodb.org/browse/JAVA-149&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/JAVA-149&lt;/a&gt;.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="12693">JAVA-144</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </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|hrhcz3:</customfieldvalue>

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