<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:31: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>[SERVER-32989] `repairDatabase` can race with `dropDatabase`.</title>
                <link>https://jira.mongodb.org/browse/SERVER-32989</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;3.6 introduced two phase drops where, with respect to &lt;tt&gt;dropDatabase&lt;/tt&gt;, all collection drops must be majority confirmed before the database drop is processed. When starting to process &lt;tt&gt;dropDatabase&lt;/tt&gt;, the in-memory &lt;tt&gt;Database&lt;/tt&gt; catalog object is marked as &lt;a href=&quot;https://github.com/mongodb/mongo/blob/f492aeddbf/src/mongo/db/catalog/drop_database.cpp#L133&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;drop pending&quot;&lt;/a&gt;. This is used to protect against things like &lt;a href=&quot;https://github.com/mongodb/mongo/blob/f492aeddbf/src/mongo/db/catalog/database_impl.cpp#L742-L745&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;collections being created&lt;/a&gt;, which is normally protected by the database lock preventing concurrent access. The problem is that when waiting for the drops to become majority confirmed, &lt;tt&gt;dropDatabase&lt;/tt&gt; &lt;a href=&quot;https://github.com/mongodb/mongo/blob/f492aeddbf/src/mongo/db/catalog/drop_database.cpp#L113-L185&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;releases all locks&lt;/a&gt;. That is done because locks should not be held by a block that is running a blocking operation.&lt;/p&gt;

&lt;p&gt;The interleaving of &lt;tt&gt;`repairDatabase`&lt;/tt&gt; and &lt;tt&gt;`dropDatabase`&lt;/tt&gt;, specifically, is amusing. &lt;tt&gt;`repairDatabase`&lt;/tt&gt; I believe deletes and recreates the in-memory `Database` object, resetting the &lt;tt&gt;`_dropPending`&lt;/tt&gt; member field to &lt;tt&gt;false&lt;/tt&gt;. This allows a &lt;tt&gt;`createCollection`&lt;/tt&gt; to now occur before the &lt;tt&gt;`dropDatabase`&lt;/tt&gt; finishes being processed.&lt;/p&gt;

&lt;p&gt;Some considerations for addressing this bug:&lt;/p&gt;

&lt;p&gt;I believe this means that anything acquiring a &lt;tt&gt;Database&lt;/tt&gt; object should check &lt;tt&gt;Database::isDropPending&lt;/tt&gt;. Additionally, it may make sense for &lt;a href=&quot;https://github.com/mongodb/mongo/blob/f492aeddbf/src/mongo/db/catalog/catalog_raii.cpp#L44-L48&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;AutoGetDb&lt;/a&gt; to check the drop pending flag as a way to centralize that logic. Note that &lt;tt&gt;repairDatabase&lt;/tt&gt; grabs a global lock, circumventing any protection the &lt;tt&gt;AutoGetDb&lt;/tt&gt; would offer.&lt;/p&gt;</description>
                <environment></environment>
        <key id="489297">SERVER-32989</key>
            <summary>`repairDatabase` can race with `dropDatabase`.</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="13201">Fixed</resolution>
                                        <assignee username="judah.schvimer@mongodb.com">Judah Schvimer</assignee>
                                    <reporter username="daniel.gottlieb@mongodb.com">Daniel Gottlieb</reporter>
                        <labels>
                            <label>rollback-non-functional</label>
                    </labels>
                <created>Tue, 30 Jan 2018 03:12:03 +0000</created>
                <updated>Sun, 29 Oct 2023 22:35:20 +0000</updated>
                            <resolved>Tue, 13 Feb 2018 18:56:05 +0000</resolved>
                                    <version>3.6.0</version>
                    <version>3.7.1</version>
                                    <fixVersion>3.6.5</fixVersion>
                    <fixVersion>3.7.3</fixVersion>
                                    <component>Replication</component>
                    <component>Storage</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1868782" author="xgen-internal-githook" created="Thu, 19 Apr 2018 14:29:11 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;judah@mongodb.com&apos;, &apos;username&apos;: &apos;judahschvimer&apos;, &apos;name&apos;: &apos;Judah Schvimer&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32989&quot; title=&quot;`repairDatabase` can race with `dropDatabase`.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-32989&quot;&gt;&lt;del&gt;SERVER-32989&lt;/del&gt;&lt;/a&gt; prevents `repairDatabase` race with `dropDatabase`&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 1e2160c8f0480a1d8be1d671b5b7e22e52986a2c)&lt;br/&gt;
Branch: v3.6&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/0982a72621b81b063a73e382ad24b707de9a3755&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/0982a72621b81b063a73e382ad24b707de9a3755&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1804591" author="xgen-internal-githook" created="Tue, 13 Feb 2018 18:32:22 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;judah@mongodb.com&apos;, &apos;name&apos;: &apos;Judah Schvimer&apos;, &apos;username&apos;: &apos;judahschvimer&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32989&quot; title=&quot;`repairDatabase` can race with `dropDatabase`.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-32989&quot;&gt;&lt;del&gt;SERVER-32989&lt;/del&gt;&lt;/a&gt; prevents `repairDatabase` race with `dropDatabase`&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/1e2160c8f0480a1d8be1d671b5b7e22e52986a2c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/1e2160c8f0480a1d8be1d671b5b7e22e52986a2c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1792493" author="judah.schvimer" created="Thu, 1 Feb 2018 22:36:14 +0000"  >&lt;p&gt;As discussed with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=daniel.gottlieb&quot; class=&quot;user-hover&quot; rel=&quot;daniel.gottlieb&quot;&gt;daniel.gottlieb&lt;/a&gt;, while other operations probably should not succeed on a database that is drop pending, a more general solution for preventing operations on databases that are drop pending is out of scope of this ticket.&lt;/p&gt;</comment>
                            <comment id="1792354" author="judah.schvimer" created="Thu, 1 Feb 2018 20:59:26 +0000"  >&lt;p&gt;To start, I will fix this race by checking if the database is drop-pending after repairDatabase takes the GlobalWrite lock, which it holds for the entire repair (I will enforce that we at least take a database X lock for repair). We only ever set the database to be drop-pending while holding an X lock on the database, so once the GlobalWrite lock is taken by repairDatabase, the database cannot be set to drop-pending until the repair completes. We call repair at the end of initial sync as well, so we must make sure this is done in both places or in the common code. &lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10420">
                    <name>Backports</name>
                                            <outwardlinks description="backported by">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="504064">SERVER-33566</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <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_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="15141"><![CDATA[v3.6]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 1 Feb 2018 20:59:26 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 42 weeks, 6 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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-842</customfieldvalue>
                        </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>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            5 years, 42 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.0</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>daniel.gottlieb@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>judah.schvimer@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htp2on:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htculz:</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_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="2106">Repl 2018-02-12</customfieldvalue>
    <customfieldvalue id="2146">Repl 2018-02-26</customfieldvalue>

                        </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|htootb:</customfieldvalue>

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