<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:39:05 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-1254] Unable to serialize extremely large volume of data (&gt;2.8GB)</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1254</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I attempted to serialize over 2.8GB of data in one go using a stream to a file on my disk, and was unable to complete the operation due to the below exception. I was originally using a pretty old version of the driver and ran into a similar integer overflow issue, so when I upgraded I decided to check whether it also affects this version, which it does.&lt;/p&gt;

&lt;p&gt;The root cause seems to be that I am trying to serialize more bytes than the Position data type can track, resulting in an overflow. I have also attached a very simple project which reproduces the issue (on my machine at least).&lt;/p&gt;

&lt;p&gt;I&apos;m sure that the workaround provided will be to split the data up but I noticed the implementation changed since my previous version to use streams rather than buffers so I had hoped this would have solved the issue.&lt;/p&gt;

&lt;p&gt;Thank you!&lt;/p&gt;

&lt;p&gt;Full exception:&lt;br/&gt;
System.ArgumentOutOfRangeException was unhandled&lt;br/&gt;
  HResult=-2146233086&lt;br/&gt;
  Message=Non-negative number required.&lt;br/&gt;
Parameter name: value&lt;br/&gt;
  Source=mscorlib&lt;br/&gt;
  ParamName=value&lt;br/&gt;
  StackTrace:&lt;br/&gt;
       at System.IO.FileStream.set_Position(Int64 value)&lt;br/&gt;
       at MongoDB.Bson.IO.BsonStreamAdapter.set_Position(Int64 value) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\IO\BsonStreamAdapter.cs:line 132&lt;br/&gt;
       at MongoDB.Bson.IO.BsonBinaryWriter.BackpatchSize() in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\IO\BsonBinaryWriter.cs:line 717&lt;br/&gt;
       at MongoDB.Bson.IO.BsonBinaryWriter.WriteEndArray() in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\IO\BsonBinaryWriter.cs:line 309&lt;br/&gt;
       at MongoDB.Bson.Serialization.Serializers.EnumerableSerializerBase`2.Serialize(BsonSerializationContext context, BsonSerializationArgs args, TValue value) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\Serializers\EnumerableSerializerBase.cs:line 317&lt;br/&gt;
       at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Serialize&lt;span class=&quot;error&quot;&gt;&amp;#91;TValue&amp;#93;&lt;/span&gt;(IBsonSerializer`1 serializer, BsonSerializationContext context, TValue value) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\IBsonSerializerExtensions.cs:line 74&lt;br/&gt;
       at MongoDB.Bson.Serialization.Serializers.EnumerableSerializerBase`2.Serialize(BsonSerializationContext context, BsonSerializationArgs args, TValue value) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\Serializers\EnumerableSerializerBase.cs:line 313&lt;br/&gt;
       at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Serialize(BsonSerializationContext context, BsonSerializationArgs args, Object value) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\Serializers\SerializerBase.cs:line 125&lt;br/&gt;
       at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Serialize(IBsonSerializer serializer, BsonSerializationContext context, Object value) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\IBsonSerializerExtensions.cs:line 61&lt;br/&gt;
       at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.SerializeNormalMember(BsonSerializationContext context, Object obj, BsonMemberMap memberMap) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\Serializers\BsonClassMapSerializer.cs:line 594&lt;br/&gt;
       at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.SerializeMember(BsonSerializationContext context, Object obj, BsonMemberMap memberMap) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\Serializers\BsonClassMapSerializer.cs:line 573&lt;br/&gt;
       at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.SerializeClass(BsonSerializationContext context, BsonSerializationArgs args, TClass document) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\Serializers\BsonClassMapSerializer.cs:line 516&lt;br/&gt;
       at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Serialize(BsonSerializationContext context, BsonSerializationArgs args, TClass value) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\Serializers\BsonClassMapSerializer.cs:line 350&lt;br/&gt;
       at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Serialize(BsonSerializationContext context, BsonSerializationArgs args, Object value) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\Serializers\SerializerBase.cs:line 125&lt;br/&gt;
       at MongoDB.Bson.Serialization.BsonSerializer.Serialize(IBsonWriter bsonWriter, Type nominalType, Object value, Action`1 configurator, BsonSerializationArgs args) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Bson\Serialization\BsonSerializer.cs:line 663&lt;br/&gt;
       at BsonDataVolume.Program.Main(String[] args) in c:\Users\chris.alexander\Documents\Visual Studio 2013\Projects\BsonDataVolume\BsonDataVolume\Program.cs:line 43&lt;br/&gt;
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)&lt;br/&gt;
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()&lt;br/&gt;
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)&lt;br/&gt;
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)&lt;br/&gt;
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)&lt;br/&gt;
       at System.Threading.ThreadHelper.ThreadStart()&lt;br/&gt;
  InnerException: &lt;/p&gt;</description>
                <environment>Windows 7 Enterprise SP1 x64 (and probably others)</environment>
        <key id="200166">CSHARP-1254</key>
            <summary>Unable to serialize extremely large volume of data (&gt;2.8GB)</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="chris_alexander">Chris Alexander</reporter>
                        <labels>
                    </labels>
                <created>Fri, 24 Apr 2015 17:57:27 +0000</created>
                <updated>Wed, 20 Jan 2016 20:09:57 +0000</updated>
                            <resolved>Wed, 20 May 2015 15:03:54 +0000</resolved>
                                    <version>1.3.1</version>
                    <version>2.0</version>
                                    <fixVersion>2.1</fixVersion>
                                    <component>BSON</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="919113" author="xgen-internal-githook" created="Wed, 20 May 2015 14:58:40 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;rstam&apos;, u&apos;name&apos;: u&apos;rstam&apos;, u&apos;email&apos;: u&apos;robert@robertstam.org&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-1254&quot; title=&quot;Unable to serialize extremely large volume of data (&amp;gt;2.8GB)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-1254&quot;&gt;&lt;del&gt;CSHARP-1254&lt;/del&gt;&lt;/a&gt;: Better error message when BackpatchSize is called and size is greater than 2GB.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/commit/fac1e0efd95c3cd8c807cdc8a42059f73dddf58b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/commit/fac1e0efd95c3cd8c807cdc8a42059f73dddf58b&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="915320" author="rstam" created="Fri, 15 May 2015 16:43:41 +0000"  >&lt;p&gt;The maximum size of a BSON document is determined by the BSON spec (see: &lt;a href=&quot;http://bsonspec.org/spec.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://bsonspec.org/spec.html&lt;/a&gt;), which uses a signed 32-bit integer to represent the size of a document. Therefore, the largest possible BSON document is  2,147,483,647 bytes long (hex 0x7fffffff).&lt;/p&gt;

&lt;p&gt;What we can do is give a better error message.&lt;/p&gt;</comment>
                            <comment id="898065" author="craiggwilson" created="Sat, 25 Apr 2015 13:45:29 +0000"  >&lt;p&gt;Ok, we should be able to get this fixed. Hopefully it doesn&apos;t require public API changes... If it does, we&apos;ll have to wait until 3.0.&lt;/p&gt;</comment>
                            <comment id="898022" author="chris_alexander" created="Sat, 25 Apr 2015 07:13:19 +0000"  >&lt;p&gt;Hi Craig&lt;/p&gt;

&lt;p&gt;Sorry I forgot to mention, that is the case - just using Bson driver to handle a bit of serialisation for me.&lt;/p&gt;

&lt;p&gt;Many thanks&lt;/p&gt;

&lt;p&gt;Chris&lt;/p&gt;</comment>
                            <comment id="897589" author="craiggwilson" created="Fri, 24 Apr 2015 17:59:47 +0000"  >&lt;p&gt;Hi Chris,&lt;/p&gt;

&lt;p&gt;Just to be thorough there, you are using the Bson library by itself without the driver. Is that correct? &lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="71919" name="BsonDataVolume.zip" size="583951" author="chris_alexander" created="Fri, 24 Apr 2015 17:57:27 +0000"/>
                    </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|hs8qxb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="549">C# Sprint 20</customfieldvalue>

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