<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:34 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-556] Wrong exception on too large query when Mongo object is not reused</title>
                <link>https://jira.mongodb.org/browse/JAVA-556</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I&apos;m using the Java driver v2.7.2 to query a sharded system consisting of 4 shards, each 3 replicas, running linux-mongodb-v2.0.1, v2.0.2 and v2.0.4. All mongos are running v2.0.1.&lt;/p&gt;

&lt;p&gt;The query I&apos;m executing is of this type: &lt;br/&gt;
{_id:{$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;1,2,3,4&amp;#93;&lt;/span&gt;}}&lt;/p&gt;

&lt;p&gt;When the inlist becomes too big (more than 265,000 id&apos;s in my case), I get the following exception, where max BSON size is greater than 2.6 times of the DBObject size:&lt;/p&gt;

&lt;p&gt;Exception in thread &quot;main&quot; com.mongodb.MongoInternalException:&lt;br/&gt;
DBObject of size 6442515 is over Max BSON size 16777216&lt;br/&gt;
        at com.mongodb.OutMessage.putObject(OutMessage.java:147)&lt;br/&gt;
        at com.mongodb.OutMessage._appendQuery(OutMessage.java:85)&lt;br/&gt;
        at com.mongodb.OutMessage.query(OutMessage.java:44)&lt;br/&gt;
        at com.mongodb.OutMessage.query(OutMessage.java:38)&lt;br/&gt;
        at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:303)&lt;br/&gt;
        at com.mongodb.DBCursor._check(DBCursor.java:369)&lt;br/&gt;
        at com.mongodb.DBCursor._hasNext(DBCursor.java:498)&lt;br/&gt;
        at com.mongodb.DBCursor.hasNext(DBCursor.java:523) &lt;/p&gt;


&lt;p&gt;When I reuse the mongo object, I don&apos;t get the exception. Moreover, I can put up to 995,000 id&apos;s into the list without any problem.&lt;br/&gt;
Exceeding the inlist size results in an appropriate exception:&lt;/p&gt;

&lt;p&gt;Exception in thread &quot;main&quot; com.mongodb.MongoException: could not&lt;br/&gt;
initialize cursor across all shards because : combinatorial limit of&lt;br/&gt;
$in partitioning of result set exceeded @ offerStoreDE4/&lt;br/&gt;
s115:27018,s132:27018,s125:27018&lt;br/&gt;
        at com.mongodb.MongoException.parse(MongoException.java:82)&lt;br/&gt;
        at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBCursor._check(DBCursor.java:369)&lt;br/&gt;
        at com.mongodb.DBCursor._hasNext(DBCursor.java:498)&lt;br/&gt;
        at com.mongodb.DBCursor.hasNext(DBCursor.java:523) &lt;/p&gt;

&lt;p&gt;However, when it&apos;s the first usage of the Mongo object then it&apos;s not yet reused and will fail as described above. &lt;/p&gt;

&lt;p&gt;For more details, please see:&lt;br/&gt;
&lt;a href=&quot;http://groups.google.com/group/mongodb-user/browse_thread/thread/3b96668396f0f9d4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://groups.google.com/group/mongodb-user/browse_thread/thread/3b96668396f0f9d4&lt;/a&gt;&lt;/p&gt;</description>
                <environment>Linux 64 Bit</environment>
        <key id="36766">JAVA-556</key>
            <summary>Wrong exception on too large query when Mongo object is not reused</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="-1">Unassigned</assignee>
                                    <reporter username="kay.agahd@idealo.de">Kay Agahd</reporter>
                        <labels>
                    </labels>
                <created>Fri, 20 Apr 2012 10:18:51 +0000</created>
                <updated>Tue, 31 Mar 2015 20:09:38 +0000</updated>
                            <resolved>Tue, 25 Jun 2013 17:50:10 +0000</resolved>
                                    <version>2.7.2</version>
                                    <fixVersion>3.0.0</fixVersion>
                                    <component>Cluster Management</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="869380" author="jeff.yemin" created="Tue, 31 Mar 2015 20:09:38 +0000"  >&lt;p&gt;Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released.&lt;/p&gt;</comment>
                            <comment id="367491" author="jeff.yemin" created="Tue, 25 Jun 2013 17:50:10 +0000"  >&lt;p&gt;See &lt;a href=&quot;https://github.com/jyemin/mongo-java-driver/commit/fa0880c#L30R89&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/jyemin/mongo-java-driver/commit/fa0880c#L30R89&lt;/a&gt;&lt;/p&gt;
</comment>
                            <comment id="111974" author="jeff.yemin" created="Fri, 20 Apr 2012 15:08:58 +0000"  >&lt;p&gt;Ah, I mis-read the code.  The first call is to Mongo.getConnector().getMaxBsonObjectSize(), while the second is to Mongo.getMaxBsonObjectSize(), which actually tries to fetch the value from the server.&lt;/p&gt;</comment>
                            <comment id="111955" author="kay.agahd@idealo.de" created="Fri, 20 Apr 2012 14:39:19 +0000"  >&lt;p&gt;Yes, I can reproduce it at any time. The size of the DBObject in the error message may vary though as for example here:&lt;/p&gt;

&lt;p&gt;Exception in thread &quot;main&quot; com.mongodb.MongoInternalException: DBObject of size 4208915 is over Max BSON size 16777216&lt;br/&gt;
	at com.mongodb.OutMessage.putObject(OutMessage.java:147)&lt;br/&gt;
	at com.mongodb.OutMessage._appendQuery(OutMessage.java:85)&lt;br/&gt;
	at com.mongodb.OutMessage.query(OutMessage.java:44)&lt;br/&gt;
	at com.mongodb.OutMessage.query(OutMessage.java:38)&lt;br/&gt;
	at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:303)&lt;br/&gt;
	at com.mongodb.DBCursor._check(DBCursor.java:369)&lt;br/&gt;
	at com.mongodb.DBCursor._hasNext(DBCursor.java:498)&lt;br/&gt;
	at com.mongodb.DBCursor.hasNext(DBCursor.java:523)&lt;/p&gt;

&lt;p&gt;&amp;gt; Am I correct that you&apos;re connecting to a replica set (by giving a list of seed servers)?&lt;/p&gt;

&lt;p&gt;No, I&apos;m connecting to one mongos like this:&lt;br/&gt;
final Mongo m = new Mongo(&quot;sx210.ipx:27018&quot;)&lt;/p&gt;</comment>
                            <comment id="111940" author="jeff.yemin" created="Fri, 20 Apr 2012 13:45:11 +0000"  >&lt;p&gt;Is this reproducible always?  It looks like a race condition.  What&apos;s happening is that Mongo.getMaxBsonObjectSize() will return 4MB when the Mongo instance is first created, since that was the default prior to 1.8.0.  When using a replica set, the value is updated by a background thread.  When running without a replica set, it&apos;s updated the first time the driver needs to find the primary/master.  Am I correct that you&apos;re connecting to a replica set (by giving a list of seed servers)?&lt;/p&gt;

&lt;p&gt;A possible workaround for you, until we can fix this, is to create the Mongo instance and then sleep in a loop until  Mongo.getMaxBsonObjectSize() returns 16MB.&lt;/p&gt;

&lt;p&gt;The confusing log message is just a symptom.  Mongo.getMaxBsonObjectSize() is called again when constructing the exception, and by the time the second call is made, the value has been updated to 16MB.&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|hrhb5z:</customfieldvalue>

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