<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:26 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-66] Inserting very large java.util.Collections into DBCollection causes a buffer overflow exception</title>
                <link>https://jira.mongodb.org/browse/JAVA-66</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;When inserting a very long list of DBObjects, a bufferoverflow exception is thrown:&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;Exception in thread &quot;main&quot; java.lang.IllegalArgumentException: tried to save too large of an object.  max size : 2098176&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;   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;	at com.mongodb.ByteEncoder.putObject(ByteEncoder.java:175)&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;   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;	at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:203)&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;   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;	at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:162)&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;   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;	at tv.miniweb.mediasearch.indexer.Indexer.Index(Indexer.java:54)&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;	at tv.miniweb.mediasearch.indexer.IndexerLauncher.main(IndexerLauncher.java:53)&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;This is because a single ByteEncoder is used for the entire .insert request, which is IMO not optimal behaviour in this case. I have pushed a git changeset with a patch and unit tests that fix this.&lt;/p&gt;</description>
                <environment></environment>
        <key id="11027">JAVA-66</key>
            <summary>Inserting very large java.util.Collections into DBCollection causes a buffer overflow exception</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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="philmes">Phil Messenger</reporter>
                        <labels>
                    </labels>
                <created>Sun, 20 Dec 2009 08:08:18 +0000</created>
                <updated>Wed, 13 Jan 2010 15:51:03 +0000</updated>
                            <resolved>Mon, 21 Dec 2009 15:43:32 +0000</resolved>
                                    <version>1.1</version>
                    <version>1.2</version>
                                    <fixVersion>1.2</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="11449" author="philmes" created="Mon, 21 Dec 2009 16:22:34 +0000"  >&lt;p&gt;Smart, knew I was missing something. Thanks for that!&lt;/p&gt;</comment>
                            <comment id="11448" author="eliot" created="Mon, 21 Dec 2009 16:21:11 +0000"  >&lt;p&gt;Not quite.&lt;br/&gt;
when writing to the buffer, limit is how far you &lt;em&gt;can&lt;/em&gt; write.&lt;/p&gt;

&lt;p&gt;From javadoc on flip:&lt;br/&gt;
Flips this buffer. The limit is set to the current position and then the position is set to zero. If the mark is defined then it is discarded.&lt;br/&gt;
&lt;a href=&quot;http://java.sun.com/j2se/1.4.2/docs/api/java/nio/Buffer.html#flip(&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://java.sun.com/j2se/1.4.2/docs/api/java/nio/Buffer.html#flip(&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;So, it sends from 0 to position.&lt;/p&gt;</comment>
                            <comment id="11447" author="philmes" created="Mon, 21 Dec 2009 16:18:33 +0000"  >&lt;p&gt;Yup, I see the position( ... ) call in DBAPILayer, but AFAIK that doesn&apos;t adjust the limit - so immediately after this it calls .flip(), which is just a delegate through to the underlying bytebuffers flip() method. doInsert( ... ) is then called, which eventually falls through to SocketChannel.write( ), which writes up to the limit() of the original byte buffer, including either the duff data or a load of blanks (which might be a performance concern?). &lt;/p&gt;

&lt;p&gt;Mind you, I don&apos;t know this code well so I could be missing something really obvious &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;
</comment>
                            <comment id="11446" author="eliot" created="Mon, 21 Dec 2009 16:06:26 +0000"  >&lt;p&gt;its not - see the change to DBAPiLayer - it moves the position back on the ByteBuffer&lt;br/&gt;
though it wouldn&apos;t be a problem anyway - just a warning message on the server.&lt;/p&gt;</comment>
                            <comment id="11445" author="philmes" created="Mon, 21 Dec 2009 16:02:19 +0000"  >&lt;p&gt;Cool, thanks for fixing. I assume it&apos;s not a problem that a chunk of data from the last-but-failed object is written to the mongod instance (guess not, the integration test passes)?&lt;/p&gt;</comment>
                            <comment id="11444" author="eliot" created="Mon, 21 Dec 2009 15:43:32 +0000"  >&lt;p&gt;fixed it a bit differently, but fixed nonetheless.&lt;/p&gt;</comment>
                            <comment id="11443" author="auto" created="Mon, 21 Dec 2009 15:43:31 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: if a bulk insert is too big for 1 buffer, break it up &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-66&quot; title=&quot;Inserting very large java.util.Collections into DBCollection causes a buffer overflow exception&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-66&quot;&gt;&lt;del&gt;JAVA-66&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/commit/76ccc51dea8453f48e3303ffeef40c761244e501&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/commit/76ccc51dea8453f48e3303ffeef40c761244e501&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="11430" author="philmes" created="Sun, 20 Dec 2009 08:10:36 +0000"  >&lt;p&gt;For reference, the push in question is&lt;/p&gt;

&lt;p&gt;2824bead0ade2deb90235a1d39f0f37699f08ba at git://github.com/philmes/mongo-java-driver.git (see &lt;a href=&quot;http://github.com/philmes/mongo-java-driver/commit/32824bead0ade2deb90235a1d39f0f37699f08ba&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/philmes/mongo-java-driver/commit/32824bead0ade2deb90235a1d39f0f37699f08ba&lt;/a&gt;)&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|hrhdf3:</customfieldvalue>

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