<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:18:24 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>[SERVER-8772] Documents with null value for hashed shard key are not returned via mongos</title>
                <link>https://jira.mongodb.org/browse/SERVER-8772</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I have a collection of 100k+ documents where about 7% are missing the field used for a hashed shard key. While you cannot shard a collection where some documents are missing the shard key field, you can if you used a hashed shard key.&lt;/p&gt;

&lt;p&gt;Prior to sharding, queries on the field (using &lt;/p&gt;
{CITY: null}
&lt;p&gt;) succeed, after sharding they appear to fail.  The query is directed to the shards and they appear to process it, but mongos does not return any documents.  Only happens if the field with null values is the shard key.&lt;/p&gt;

&lt;p&gt;Have reproduced with mongo shell and pymongo, have not narrowed down enough to write JS test case.&lt;/p&gt;

&lt;p&gt;Am not seeing any obvious errors in my &lt;tt&gt;mongos&lt;/tt&gt; or &lt;tt&gt;mongod&lt;/tt&gt; logs.&lt;/p&gt;</description>
                <environment>OS X, 3 shards on 3 replica sets, 1 mongos</environment>
        <key id="66719">SERVER-8772</key>
            <summary>Documents with null value for hashed shard key are not returned via mongos</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="aaron">Aaron Staple</assignee>
                                    <reporter username="epc">Ed Costello</reporter>
                        <labels>
                    </labels>
                <created>Wed, 27 Feb 2013 21:04:22 +0000</created>
                <updated>Mon, 11 Jul 2016 17:56:22 +0000</updated>
                            <resolved>Mon, 4 Mar 2013 21:59:24 +0000</resolved>
                                    <version>2.4.0-rc1</version>
                                    <fixVersion>2.4.0-rc2</fixVersion>
                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="282680" author="epc" created="Wed, 6 Mar 2013 17:06:30 +0000"  >&lt;p&gt;Am retesting this afternoon (6 March)&lt;/p&gt;</comment>
                            <comment id="281356" author="aaron" created="Mon, 4 Mar 2013 23:42:12 +0000"  >&lt;p&gt;commit 696dec1262372b0ac45bad9c84de4700eb0d2e71&lt;br/&gt;
Author: aaron &amp;lt;aaron@10gen.com&amp;gt;&lt;br/&gt;
Date:   Sun Mar 3 11:38:44 2013 -0500&lt;/p&gt;

&lt;p&gt;    Make the IndexSpec::missingField() implementation IndexType specific, and use missingField() to properly identify missing fields in CheckShardingIndex::run().&lt;/p&gt;</comment>
                            <comment id="279955" author="dan@10gen.com" created="Sat, 2 Mar 2013 22:14:51 +0000"  >&lt;p&gt;Adding a test case for sharding on existing collection using single, compound and hashed shard key.&lt;/p&gt;

&lt;p&gt;Can special case hashed shard keys and check for hashed value of null instead.&lt;/p&gt;</comment>
                            <comment id="279622" author="aaron" created="Sat, 2 Mar 2013 05:43:51 +0000"  >&lt;p&gt;This is not code I&apos;m super familiar with, but it looks like running the shardCollection command on mongos sends out checkShardingIndex commands to the mongods.  And checkShardingIndex checks for index keys where the shard key is null, indicating that a shard key field may be absent from a document, from CheckShardingIndex::run():&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                    if ( currKeyElt.type() &amp;amp;&amp;amp; currKeyElt.type() != jstNULL )&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                        continue;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Hash indexes don&apos;t store a key of null for a missing field, but instead they store the hash of null.  Missing values cannot be identified by the presence of null index keys in the current hash index implementation.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="24502" name="headers.h" size="296" author="epc" created="Wed, 27 Feb 2013 21:04:22 +0000"/>
                            <attachment id="24646" name="missing_key.js" size="1000" author="dan@mongodb.com" created="Sat, 2 Mar 2013 22:14:51 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sat, 2 Mar 2013 00:07:08 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 50 weeks ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 50 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aaron</customfieldvalue>
            <customfieldvalue>dan@mongodb.com</customfieldvalue>
            <customfieldvalue>epc</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrn3yf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrmesf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>44349</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;Import the 2009 NYS campaign finance database &lt;a href=&quot;http://www.elections.ny.gov/NYSBOE/download/ZipDataFiles/2009gen.zip&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.elections.ny.gov/NYSBOE/download/ZipDataFiles/2009gen.zip&lt;/a&gt; using mongoimport -d qa -c gen2009 -fieldFile headers.h --ignoreBlanks --type csv 2009gen.out (note that headers.h is attached to this ticket)&lt;br/&gt;
mongo&lt;br/&gt;
&amp;gt; use qa&lt;br/&gt;
&amp;gt; db.gen2009.ensureIndex(&lt;/p&gt;
{CITY:&quot;hashed&quot;}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.gen2009.find(&lt;/p&gt;
{CITY:null}
&lt;p&gt;) should return 7463 documents&lt;br/&gt;
&amp;gt; sh.enableSharding(&quot;qa&quot;)&lt;br/&gt;
&amp;gt; sh.shardCollection(&quot;qa.gen2009&quot;, &lt;/p&gt;
{CITY:&quot;hashed&quot;}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.gen2009.find(&lt;/p&gt;
{CITY:null}
&lt;p&gt;) -returns no documents&lt;br/&gt;
&amp;gt; db.gen2009.find(&lt;/p&gt;
{CITY:null}
&lt;p&gt;).count() returns 7463&lt;br/&gt;
&amp;gt; db.gen2009.find(&lt;/p&gt;
{STATE:null}
&lt;p&gt;).count() returns 7322 documents&lt;/p&gt;
</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hsx5lr:</customfieldvalue>

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