<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:35:56 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-143] InsertBatch Exception WHEN the item of object too large</title>
                <link>https://jira.mongodb.org/browse/CSHARP-143</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I have a List&amp;lt;&amp;gt; object in C# with about 100000 items,When I use the InsertBatch&amp;lt;&amp;gt; method to Insert these data into mongodb,It got exception and data can&apos;t  insert into db.&lt;/p&gt;</description>
                <environment>VS2010&lt;br/&gt;
mongodb 1.6.5&lt;br/&gt;
win7</environment>
        <key id="14090">CSHARP-143</key>
            <summary>InsertBatch Exception WHEN the item of object too large</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="xuqing">xuqing</reporter>
                        <labels>
                    </labels>
                <created>Tue, 28 Dec 2010 02:30:19 +0000</created>
                <updated>Thu, 2 Apr 2015 18:28:24 +0000</updated>
                            <resolved>Tue, 28 Dec 2010 05:52:29 +0000</resolved>
                                    <version>0.9</version>
                                    <fixVersion>1.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="21858" author="testn" created="Tue, 28 Dec 2010 06:56:04 +0000"  >&lt;p&gt;the limit is 16MB in 1.6 and 48MB in 1.7 but it includes the entire message length not just the data.&lt;/p&gt;

&lt;p&gt;struct MsgHeader {&lt;br/&gt;
    int32   messageLength; // total message size, including this&lt;br/&gt;
    int32   requestID;     // identifier for this message&lt;br/&gt;
    int32   responseTo;    // requestID from the original request&lt;br/&gt;
                           //   (used in reponses from db)&lt;br/&gt;
    int32   opCode;        // request type - see table below&lt;br/&gt;
}&lt;/p&gt;</comment>
                            <comment id="21852" author="rstam" created="Tue, 28 Dec 2010 05:52:29 +0000"  >&lt;p&gt;First there was a typo in the definition of MongoDefaults.MaxMessageLength, so the value was higher than 16MB. Second, the server doesn&apos;t seem to like 16MB either, so I reduced the maximum message length to 12MB (at least for now).&lt;/p&gt;</comment>
                            <comment id="21844" author="rstam" created="Tue, 28 Dec 2010 04:13:15 +0000"  >&lt;p&gt;Excellent information. Thanks. I will try to reproduce.&lt;/p&gt;</comment>
                            <comment id="21841" author="xuqing" created="Tue, 28 Dec 2010 04:01:32 +0000"  >&lt;p&gt;StackTrace:   &lt;/p&gt;

&lt;p&gt;At System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)  At MongoDB.Bson.IO.BsonBuffer.WriteTo(Stream stream)&lt;br/&gt;
At MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, SafeMode safeMode)&lt;br/&gt;
At MongoDB.Driver.MongoCollection.InsertBatch&lt;span class=&quot;error&quot;&gt;&amp;#91;TDocument&amp;#93;&lt;/span&gt;(IEnumerable`1 documents, SafeMode safeMode)&lt;br/&gt;
At MongoWriteSpeed.Program.Main(String[] args) Location E:\Test\WindowsProject\MongoWriteSpeed\MongoWriteSpeed\Program.cs:Row 68&lt;/p&gt;</comment>
                            <comment id="21840" author="xuqing" created="Tue, 28 Dec 2010 03:57:19 +0000"  >&lt;p&gt;And Out Put of Program is Below:&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;11:56:05.096&amp;#93;&lt;/span&gt;?Init&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;11:56:05.163&amp;#93;&lt;/span&gt;?Connect To Mongo&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;11:56:06.304&amp;#93;&lt;/span&gt;?Get Document tTest&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;11:56:06.328&amp;#93;&lt;/span&gt;?Create Data&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;11:56:08.702&amp;#93;&lt;/span&gt;?Data Ready?Begin Write 100000 Data&lt;br/&gt;
Faile?Exception?Can not write data to transport connection: remote host forced to shut down an existing connection. .&lt;/p&gt;</comment>
                            <comment id="21839" author="xuqing" created="Tue, 28 Dec 2010 03:55:41 +0000"  >&lt;p&gt;My Program is Below:&lt;/p&gt;

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

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

&lt;p&gt;namespace MongoTest&lt;br/&gt;
{&lt;br/&gt;
    class Program&lt;br/&gt;
    {&lt;br/&gt;
        static void Main(string[] args)&lt;br/&gt;
        {&lt;br/&gt;
            DateTime _dtStart, _dtEnd;&lt;br/&gt;
            System.Console.WriteLine(string.Format(&quot;[&lt;/p&gt;
{0}]?Init&quot;, DateTime.Now.ToString(&quot;HH:mm:ss.fff&quot;)));&lt;br/&gt;
&lt;br/&gt;
            MongoServer _dbServer = MongoServer.Create();&lt;br/&gt;
&lt;br/&gt;
            try&lt;br/&gt;
            {&lt;br/&gt;
                if ((_dbServer.State == MongoServerState.Disconnected) || (_dbServer.State == MongoServerState.None))&lt;br/&gt;
                {&lt;br/&gt;
                    System.Console.WriteLine(string.Format(&quot;[{0}
&lt;p&gt;]?Connect To Mongo&quot;, DateTime.Now.ToString(&quot;HH:mm:ss.fff&quot;)));&lt;/p&gt;

&lt;p&gt;                    _dbServer.Connect();&lt;/p&gt;

&lt;p&gt;                    System.Console.WriteLine(string.Format(&quot;[&lt;/p&gt;
{0}]?Get Document tTest&quot;, DateTime.Now.ToString(&quot;HH:mm:ss.fff&quot;)));&lt;br/&gt;
&lt;br/&gt;
                    MongoDatabase _db = _dbServer.GetDatabase(&quot;test&quot;);&lt;br/&gt;
&lt;br/&gt;
                    if (_db.CollectionExists(&quot;tTest&quot;))&lt;br/&gt;
                    {
                        _db.DropCollection(&quot;tTest&quot;);
                    }&lt;br/&gt;
&lt;br/&gt;
                    MongoCollection&amp;lt;MongoDB.Bson.BsonDocument&amp;gt; _document = _db.GetCollection(&quot;tTest&quot;);&lt;br/&gt;
&lt;br/&gt;
                    List&amp;lt;MongoDB.Bson.BsonDocument&amp;gt; _insertDoc = new List&amp;lt;BsonDocument&amp;gt;();&lt;br/&gt;
&lt;br/&gt;
                    int _iRowsCount = 100000;&lt;br/&gt;
&lt;br/&gt;
                    System.Console.WriteLine(string.Format(&quot;[{0}
&lt;p&gt;]?Create Data&quot;, DateTime.Now.ToString(&quot;HH:mm:ss.fff&quot;), _iRowsCount));&lt;/p&gt;

&lt;p&gt;                    TimeSpan _ts = new TimeSpan(0);&lt;/p&gt;

&lt;p&gt;                    for (int i = 0; i &amp;lt; _iRowsCount; i++)&lt;br/&gt;
                    {&lt;br/&gt;
                        List&amp;lt;MongoDB.Bson.BsonElement&amp;gt; _eleList = new List&amp;lt;BsonElement&amp;gt;();&lt;/p&gt;

&lt;p&gt;                        _eleList.Add(new BsonElement(&quot;dtInsert&quot;, (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;sWxAccount&quot;, &quot;test&quot;));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;sIP&quot;, &quot;127.0.0.1&quot;));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;sPc&quot;, string.Format(&quot;PC-&lt;/p&gt;
{0}&quot;, i)));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;iGameId&quot;, i));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;sProcGuid&quot;, System.Guid.NewGuid().ToString()));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;dtSniff&quot;, (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;sCardNo&quot;, &quot;&quot;));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;sSex&quot;, &quot;Un Known&quot;));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;iAge&quot;, 0));&lt;br/&gt;
                        _eleList.Add(new BsonElement(&quot;iState&quot;, 1));&lt;br/&gt;
&lt;br/&gt;
                        _insertDoc.Add(new BsonDocument(_eleList));&lt;br/&gt;
                    }&lt;br/&gt;
&lt;br/&gt;
                    System.Console.WriteLine(string.Format(&quot;[{0}
&lt;p&gt;]?Data Ready?Begin Write &lt;/p&gt;
{1} Data&quot;, DateTime.Now.ToString(&quot;HH:mm:ss.fff&quot;), _iRowsCount));&lt;br/&gt;
                    _dtStart = DateTime.Now;&lt;br/&gt;
                    _document.InsertBatch(_insertDoc,SafeMode.True);&lt;br/&gt;
                    &lt;br/&gt;
                    _dtEnd = DateTime.Now;&lt;br/&gt;
&lt;br/&gt;
                    _ts = _dtEnd.Subtract(_dtStart);&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
                    System.Console.WriteLine(string.Format(&quot;&lt;span class=&quot;error&quot;&gt;&amp;#91;{0}&amp;#93;&lt;/span&gt;?{1}
&lt;p&gt; Write Success&quot;, DateTime.Now.ToString(&quot;HH:mm:ss.fff&quot;), _iRowsCount));&lt;/p&gt;

&lt;p&gt;                    System.Console.WriteLine(string.Format(&quot;Done?Take time?&lt;/p&gt;
{0}H{1}M{2}S{3}MS&quot;, _ts.Hours, _ts.Minutes, _ts.Seconds, _ts.Milliseconds));&lt;br/&gt;
                }&lt;br/&gt;
            }&lt;br/&gt;
            catch (Exception ex)&lt;br/&gt;
            {&lt;br/&gt;
                System.Console.WriteLine(string.Format(&quot;Faile?Exception?{0}
&lt;p&gt;&quot;, ex.Message));&lt;br/&gt;
            }&lt;br/&gt;
            finally&lt;/p&gt;
            {
                _dbServer.Disconnect();
            }
&lt;p&gt;        }&lt;br/&gt;
    }&lt;br/&gt;
}&lt;/p&gt;</comment>
                            <comment id="21838" author="rstam" created="Tue, 28 Dec 2010 03:06:01 +0000"  >&lt;p&gt;Can you provide an error message and a stack trace? And perhaps a description of the document you are trying to save. Do you mean you have a list of 100000 documents, or a document that has an internal list of 100000 values?&lt;/p&gt;

&lt;p&gt;There is a maximum size to a document, you may just be reaching this limit. The limit is currently 4MB but will be increasing.&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|hrh9fz:</customfieldvalue>

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