<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:04 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-192] Max BSON Document Size is 4MB when should be 16GB, Generating Read Errors</title>
                <link>https://jira.mongodb.org/browse/CSHARP-192</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;In MongoDB.Bson.BsonDefaults, &lt;br/&gt;
        private static int maxDocumentSize = 4 * 1024 * 1024; // 4MB&lt;/p&gt;

&lt;p&gt;should be:&lt;br/&gt;
        private static int maxDocumentSize = 4 * 1024 * 1024 * 4; // 4MB * 4 = 16MB&lt;/p&gt;

&lt;p&gt;Otherwise, during a Read, the ReadSize method throws an error:&lt;/p&gt;

&lt;p&gt;private int ReadSize() {&lt;br/&gt;
            int size = buffer.ReadInt32();&lt;br/&gt;
            if (size &amp;lt; 0) &lt;/p&gt;
{
                throw new FileFormatException(&quot;Size is negative&quot;);
            }
&lt;p&gt;            if (size &amp;gt; settings.MaxDocumentSize) &lt;/p&gt;
{
                throw new FileFormatException(&quot;Size is larger than MaxDocumentSize&quot;);
            }
&lt;p&gt;            return size;&lt;br/&gt;
        }&lt;/p&gt;</description>
                <environment></environment>
        <key id="15465">CSHARP-192</key>
            <summary>Max BSON Document Size is 4MB when should be 16GB, Generating Read Errors</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="alexkaminski">Alex Kaminski</reporter>
                        <labels>
                    </labels>
                <created>Mon, 4 Apr 2011 23:23:06 +0000</created>
                <updated>Thu, 2 Apr 2015 18:28:31 +0000</updated>
                            <resolved>Tue, 5 Apr 2011 00:10:26 +0000</resolved>
                                    <version>0.9</version>
                                    <fixVersion>0.11</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="27785" author="rstam" created="Tue, 5 Apr 2011 00:10:26 +0000"  >&lt;p&gt;Feature was added in v0.11, so v0.9 did not support this.&lt;/p&gt;</comment>
                            <comment id="27784" author="alexkaminski" created="Tue, 5 Apr 2011 00:05:36 +0000"  >&lt;p&gt;Yes, it probably is because we&apos;re using an older driver. There is no MaxDocumentSize property on the MongoServer object (for the driver we&apos;re using). &lt;/p&gt;

&lt;p&gt;I got the driver source code for our version + edited, so we got rid of the error. Glad to know, the new driver fixed this error by auto detecting the max size. We&apos;ll probably be upgrading to the new driver soon. &lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="27782" author="rstam" created="Mon, 4 Apr 2011 23:50:33 +0000"  >&lt;p&gt;Thanks for the reply. When I run this program:&lt;/p&gt;

&lt;p&gt;using System;&lt;br/&gt;
using System.Collections.Generic;&lt;br/&gt;
using System.Linq;&lt;br/&gt;
using System.Text;&lt;/p&gt;

&lt;p&gt;using MongoDB.Bson;&lt;br/&gt;
using MongoDB.Driver;&lt;/p&gt;

&lt;p&gt;namespace Test16MBDocument {&lt;br/&gt;
    public static class Program {&lt;br/&gt;
        public static void Main(string[] args) {&lt;br/&gt;
            var server = MongoServer.Create(&quot;mongodb://localhost/?safe=true&quot;);&lt;br/&gt;
            server.Connect();&lt;br/&gt;
            Console.WriteLine(&quot;Max document size is: &lt;/p&gt;
{0}
&lt;p&gt;&quot;, server.MaxDocumentSize);&lt;br/&gt;
            Console.ReadLine();&lt;br/&gt;
        }&lt;br/&gt;
    }&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;I get:&lt;/p&gt;

&lt;p&gt;Max document size is: 16777216&lt;/p&gt;

&lt;p&gt;Could you run this same program on your client computer (changing the host name) and see what you get?&lt;/p&gt;

&lt;p&gt;The problem is likely because you are on a rather old version of the driver (v0.9). It probably didn&apos;t yet have the feature of dynamically adjusting the max document size depending on which server it connected to. There have been two more releases since v0.9 came out. I recommend you use v1.0, although be prepared to deal with some minor breaking changes (see the release notes for v0.11 and v1.0).&lt;/p&gt;</comment>
                            <comment id="27781" author="alexkaminski" created="Mon, 4 Apr 2011 23:39:36 +0000"  >&lt;p&gt;Yes, I was getting the error every time it would try to read a large document: &lt;/p&gt;

&lt;p&gt;System.IO.FileFormatException: Size is larger than MaxDocumentSize&lt;br/&gt;
   at MongoDB.Bson.IO.BsonBinaryReader.ReadSize()&lt;br/&gt;
   at MongoDB.Bson.IO.BsonBinaryReader.ReadStartDocument()&lt;br/&gt;
   at MongoDB.Bson.DefaultSerializer.Conventions.StandardDiscriminatorConvention.GetActualType(BsonReader bsonReader, Type nominalType)&lt;br/&gt;
   at MongoDB.Bson.DefaultSerializer.BsonClassMapSerializer.Deserialize(BsonReader bsonReader, Type nominalType)&lt;br/&gt;
   at MongoDB.Bson.Serialization.BsonSerializer.Deserialize(BsonReader bsonReader, Type nominalType)&lt;br/&gt;
   at MongoDB.Bson.Serialization.BsonSerializer.Deserialize&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;(BsonReader bsonReader)&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(BsonBuffer buffer)&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage&lt;span class=&quot;error&quot;&gt;&amp;#91;TDocument&amp;#93;&lt;/span&gt;()&lt;br/&gt;
   at MongoDB.Driver.MongoCursor`1.MongoCursorEnumerator.GetReply(MongoRequestMessage message)&lt;br/&gt;
   at MongoDB.Driver.MongoCursor`1.MongoCursorEnumerator.GetFirst()&lt;br/&gt;
   at MongoDB.Driver.MongoCursor`1.MongoCursorEnumerator.MoveNext()&lt;br/&gt;
   at System.Linq.Enumerable.FirstOrDefault&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;br/&gt;
   at MongoDB.Driver.MongoCollection.FindOneAs&lt;span class=&quot;error&quot;&gt;&amp;#91;TDocument&amp;#93;&lt;/span&gt;(IMongoQuery query)&lt;br/&gt;
   at MongoDB.Driver.MongoCollection`1.FindOne(IMongoQuery query)&lt;/p&gt;

&lt;p&gt;Changing it to 16MB, did fix it. We are on 1.8, so it should be 16mb - maybe that part isn&apos;t being automatically set correctly?&lt;/p&gt;

&lt;p&gt;This is on a multi-threaded app; and we&apos;re logging an error every 1-50ms. We&apos;re using the 0.9 RC driver. &lt;/p&gt;</comment>
                            <comment id="27780" author="rstam" created="Mon, 4 Apr 2011 23:33:17 +0000"  >&lt;p&gt;The 4MB value you pointed out is only an initial default. When you connect to a server the value for that &lt;b&gt;particular&lt;/b&gt; server is updated depending on which version of the server you connect to.&lt;/p&gt;

&lt;p&gt;Can you confirm that you actually got an error, or are you just concerned about seeing the 4MB value?&lt;/p&gt;</comment>
                            <comment id="27778" author="alexkaminski" created="Mon, 4 Apr 2011 23:24:31 +0000"  >&lt;p&gt;If you guys added unit tests with large BsonDocuments, this would have been caught. &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|hrh95r:</customfieldvalue>

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