<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:05:08 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>[SERVER-4159] Dataloss on sharded environment when one server in a replicaset goes down (ungracefully shuts down)</title>
                <link>https://jira.mongodb.org/browse/SERVER-4159</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;In the scenario where the primary service of a one shard in a sharded collection goes down, we are getting some document losses in safe mode (even with fsync=true) on a record by record based insert (no batches)&lt;/p&gt;

&lt;p&gt;We have built in some failover code, where we keep retrying the insert untill the safemode no longer throws an exception. However, even with this setup, we still see some document loss.&lt;/p&gt;

&lt;p&gt;These losses occur on 2 moments (we ran some tests trying to determine the cause):&lt;br/&gt;
1) the moment the primary goes down and a secondary needs to take over&lt;br/&gt;
2) the moment the primary goes back online, and is voted for primary again in its replset (when looking on the replset stats, there is a moment when both servers are marked as secundary)&lt;/p&gt;

&lt;p&gt;On a recordset of 50.000 records, we get somewhere between 5-10 document losses.&lt;/p&gt;

&lt;p&gt;Enabling the option to wait for a replication write in the safe mode is hard to use in our case, since that would mean it would enter an endless loop to retry to insert the document, unless we expand our failover code to catch for this case as well. However, we think this should be handled on the database itself, rather then in code...&lt;/p&gt;

&lt;p&gt;Here&apos;s how we&apos;re inserting right now (code without fsync option):&lt;/p&gt;

&lt;p&gt;var safe = new SafeMode(true);&lt;br/&gt;
var opts = new MongoInsertOptions(tdCollection);&lt;br/&gt;
opts.SafeMode = safe;&lt;/p&gt;

&lt;p&gt;for (int i = 0; i &amp;lt; 50000; i++)&lt;br/&gt;
{&lt;br/&gt;
    try&lt;br/&gt;
    {&lt;/p&gt;

&lt;p&gt;      var td = new TestClass();&lt;br/&gt;
      td.Number = i;&lt;br/&gt;
      td.NumberAsString = i.ToString();&lt;br/&gt;
      td.Number2 = i * 2;&lt;br/&gt;
      bool ok = false;&lt;br/&gt;
      while (!ok)&lt;br/&gt;
      {&lt;br/&gt;
          try&lt;/p&gt;
          {
              var result = tdCollection.Insert(td, opts);
              ok = result.Ok;
          }
&lt;p&gt;          catch (Exception ex)&lt;/p&gt;
          {
              Console.WriteLine(ex);
              ok = false;
          }
&lt;p&gt;       }&lt;br/&gt;
       Console.WriteLine&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/information.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;;&lt;br/&gt;
     }&lt;br/&gt;
     catch (Exception ex)&lt;/p&gt;
     {
         Console.WriteLine(ex.Message);
     }
&lt;p&gt;   }&lt;br/&gt;
Console.WriteLine(&quot;Done writing 500000 records&quot;);&lt;/p&gt;

&lt;p&gt;Is there something we overlooked? Or is this a bug?&lt;/p&gt;

&lt;p&gt;Thanks in advance...&lt;/p&gt;</description>
                <environment>Windows server 2008 64bit, sharded mongoD (3 shards, each are replicasets with 2 servers, so 3 replsets with 2 servers each), 1 mongoS on seperate server, C# driver</environment>
        <key id="24143">SERVER-4159</key>
            <summary>Dataloss on sharded environment when one server in a replicaset goes down (ungracefully shuts down)</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="spencer@mongodb.com">Spencer Brody</assignee>
                                    <reporter username="wouteralleweireldt">wouter alleweireldt</reporter>
                        <labels>
                    </labels>
                <created>Thu, 27 Oct 2011 08:48:35 +0000</created>
                <updated>Mon, 11 Jul 2016 18:35:08 +0000</updated>
                            <resolved>Sat, 3 Dec 2011 00:33:48 +0000</resolved>
                                    <version>2.0.1</version>
                                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="70613" author="spencer" created="Sat, 3 Dec 2011 00:33:48 +0000"  >&lt;p&gt;I&apos;m going to go ahead and resolve this issue. If you are still having problems with this feel free to re-open.&lt;/p&gt;</comment>
                            <comment id="63976" author="spencer" created="Tue, 1 Nov 2011 15:49:00 +0000"  >&lt;p&gt;The only way you can be sure that written data won&apos;t be lost on replica set failover is if you ensure that the write is propagated to a majority of nodes in the set before acknowledging it.  As Eliot mentioned, this can be done using the w flag on inserts.  You can specify the number of nodes to wait for the write to propagate to, or in 2.0 you can specify w=&apos;majority&apos;, which will ensure that the write goes to a majority of members in the set.  If you&apos;re doing this, it is probably a good idea to set a wtimeout so that the operation won&apos;t hang indefinitely if there&apos;s a problem.  Then you can have your application code retry some number of times before reporting the error back to the user.&lt;/p&gt;</comment>
                            <comment id="63070" author="eliot" created="Thu, 27 Oct 2011 15:19:31 +0000"  >&lt;p&gt;You should try adding w=2.&lt;br/&gt;
That will guarantee a write went through to a secondary.&lt;br/&gt;
fsync doesn&apos;t actually help much or at all in this case.&lt;/p&gt;</comment>
                            <comment id="63014" author="eliot" created="Thu, 27 Oct 2011 12:05:41 +0000"  >&lt;p&gt;Will the c# driver throw an exception if there is an error or just have ok an error set?&lt;br/&gt;
You be getting an error in the code when that happens&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 27 Oct 2011 12:05:41 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        12 years, 11 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            12 years, 11 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10022"><![CDATA[Windows]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>spencer@mongodb.com</customfieldvalue>
            <customfieldvalue>wouteralleweireldt</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hron27:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hriqtb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>22997</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrlfu7:</customfieldvalue>

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