<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:36:59 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-34531] listDatabases command can miss a database if a collection in that database is renamed concurrently</title>
                <link>https://jira.mongodb.org/browse/SERVER-34531</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;It is possible for the &lt;tt&gt;listDatabases&lt;/tt&gt; command to erroneously omit a database if the database contains a single collection and that collection is concurrently renamed. The problem stems from the fact that the &lt;tt&gt;listDatabases&lt;/tt&gt; command takes a &lt;a href=&quot;https://github.com/mongodb/mongo/blob/master/src/mongo/db/commands/list_databases.cpp?utf8=%E2%9C%93#L116-L119&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;GlobalLock in MODE_IS&lt;/a&gt;. The &lt;tt&gt;renameCollection&lt;/tt&gt; command acquires a GlobalLock in MODE_IX and &lt;a href=&quot;https://github.com/mongodb/mongo/blob/2b20c142c7e15cdad1ef609bcb5f14ba288dacea/src/mongo/db/catalog/rename_collection.cpp#L136&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;a MODE_X&lt;/a&gt; database lock on the database on which it is performing the rename. Global locks of type IX and IS do not conflict, so the &lt;tt&gt;listDatabases&lt;/tt&gt; command and &lt;tt&gt;renameCollection&lt;/tt&gt; command are allowed to run concurrently.&lt;/p&gt;

&lt;p&gt;When the &lt;tt&gt;renameCollection&lt;/tt&gt; command &lt;a href=&quot;https://github.com/mongodb/mongo/blob/master/src/mongo/db/catalog/rename_collection.cpp#L240&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;executes a rename within the same database&lt;/a&gt;, it will call &lt;a href=&quot;https://github.com/mongodb/mongo/blob/2b20c142c7e15cdad1ef609bcb5f14ba288dacea/src/mongo/db/catalog/database_impl.cpp#L661&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;DatabaseImpl::renameCollection&lt;/a&gt;, which as part of the rename operation, will call &lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.7.9/src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp#L279&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;KVDatabaseCatalogEntryBase::renameCollection&lt;/tt&gt;&lt;/a&gt; and &lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.7.9/src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp#L315-L319&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;remove the entry for the source collection&lt;/a&gt; from &lt;tt&gt;KVDatabaseCatalogEntryBase::_collections&lt;/tt&gt;.&#160;It will then insert the entry for the destination collection to the structure &lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.7.9/src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp#L327-L328&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;, before it finishes. If there was only one collection in the database, the &lt;tt&gt;KVDatabaseCatalogEntryBase::_collections&lt;/tt&gt; structure will be empty until the entry for the destination collection is added. If, during this period, a &lt;tt&gt;listDatabases&lt;/tt&gt; command is running, it is possible that it will view the database object in this state and consider it to be empty. It &lt;a href=&quot;https://github.com/mongodb/mongo/blob/9abef6f25aadfd04309cb2219068097f93dc961d/src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp#L132-L134&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;checks for the &quot;emptiness&quot;&lt;/a&gt; of &lt;tt&gt;KVDatabaseCatalogEntryBase::_collections&lt;/tt&gt; &lt;a href=&quot;https://github.com/mongodb/mongo/blob/2b20c142c7e15cdad1ef609bcb5f14ba288dacea/src/mongo/db/storage/kv/kv_storage_engine.cpp#L373&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;, in &lt;tt&gt;KVStorageEngine::listDatabases&lt;/tt&gt;. This can cause this database to be missed, even though it should exist.&lt;/p&gt;

&lt;p&gt;This can be a problem internally, for example, for initial sync, which relies on the correctness of the results returned by the &lt;tt&gt;listDatabases&lt;/tt&gt; command for its collection cloning process.&lt;/p&gt;

&lt;p&gt;There is a repro attached demonstrating how the listDatabases command can produce incorrect results. There is also a repro attached demonstrating how this issue could lead to a collection missing on a node following initial sync. Running these tests on repeat for a few runs should produce the respective error cases.&lt;/p&gt;</description>
                <environment></environment>
        <key id="529900">SERVER-34531</key>
            <summary>listDatabases command can miss a database if a collection in that database is renamed concurrently</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="maria.vankeulen@mongodb.com">Maria van Keulen</assignee>
                                    <reporter username="william.schultz@mongodb.com">William Schultz</reporter>
                        <labels>
                            <label>nyc</label>
                    </labels>
                <created>Tue, 17 Apr 2018 21:46:52 +0000</created>
                <updated>Sun, 29 Oct 2023 22:32:37 +0000</updated>
                            <resolved>Tue, 15 May 2018 13:35:40 +0000</resolved>
                                                    <fixVersion>4.0.0-rc0</fixVersion>
                                    <component>Replication</component>
                    <component>Storage</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="1891498" author="xgen-internal-githook" created="Tue, 15 May 2018 13:33:47 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;maria@mongodb.com&apos;, &apos;username&apos;: &apos;mvankeulen94&apos;, &apos;name&apos;: &apos;Maria van Keulen&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-34531&quot; title=&quot;listDatabases command can miss a database if a collection in that database is renamed concurrently&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-34531&quot;&gt;&lt;del&gt;SERVER-34531&lt;/del&gt;&lt;/a&gt; Ensure KVCatalog _collections is not empty during rename&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/0192520fa62db28787a5fb6ad828c1723d7d992c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/0192520fa62db28787a5fb6ad828c1723d7d992c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1886004" author="maria.vankeulen" created="Tue, 8 May 2018 16:07:49 +0000"  >&lt;p&gt;I believe the bug occurs due to the &lt;tt&gt;KVDatabaseCatalogEntryBase::_collections&lt;/tt&gt; object rather than the &lt;tt&gt;DatabaseImpl::_collections&lt;/tt&gt; object. Hence, I believe this can be fixed at the &lt;tt&gt;KVDatabaseCatalogEntryBase&lt;/tt&gt; level. I have updated the ticket description.&lt;/p&gt;</comment>
                            <comment id="1867911" author="william.schultz" created="Wed, 18 Apr 2018 17:53:37 +0000"  >&lt;p&gt;I was able to reproduce this on 3.6 and 3.4.&lt;/p&gt;</comment>
                            <comment id="1867057" author="spencer" created="Tue, 17 Apr 2018 22:18:01 +0000"  >&lt;p&gt;Ah I see, I was thinking about the collection getting renamed out of the database, not about it being renamed within the same db.  Agreed that is a bug.&lt;/p&gt;</comment>
                            <comment id="1867049" author="william.schultz" created="Tue, 17 Apr 2018 22:01:42 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=spencer&quot; class=&quot;user-hover&quot; rel=&quot;spencer&quot;&gt;spencer&lt;/a&gt; You are correct that if a database has no collections, it effectively does not exist, and so we should not need to copy anything for initial sync. But if a database contains a single collection, that is in the middle of being renamed within that database, it is incorrect for a listDatabases command to not include that database in its result set, since the database most certainly exists. The problem is that the listDatabases command is not viewing the renameCollection as a single atomic operation. If a collection exists in database &quot;test&quot;, and that collection gets renamed to a different name in the same database, I would consider it an invariant that listDatabases always includes &quot;test&quot; in its list of results; before, during, and after the renameCollection operation.&lt;/p&gt;</comment>
                            <comment id="1867030" author="spencer" created="Tue, 17 Apr 2018 21:49:55 +0000"  >&lt;p&gt;I&apos;m confused how this causes an issue in initial sync.  If the database has no collections in it, then effectively the database doesn&apos;t exist.  Why would it be a problem for it to not show up in listDatabases?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="542820">SERVER-34968</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="532591">SERVER-34615</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="616718">SERVER-37552</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="184334" name="initial_sync_concurrent_renames.js" size="1059" author="william.schultz@mongodb.com" created="Tue, 17 Apr 2018 21:36:18 +0000"/>
                            <attachment id="184335" name="list_databases_and_rename_collection.js" size="1236" author="william.schultz@mongodb.com" created="Tue, 17 Apr 2018 21:36:03 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.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_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>Tue, 17 Apr 2018 21:49:55 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 39 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/SERVER-34968'>SERVER-34968</a></s>]]></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>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, 39 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>63.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>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>maria.vankeulen@mongodb.com</customfieldvalue>
            <customfieldvalue>spencer@mongodb.com</customfieldvalue>
            <customfieldvalue>william.schultz@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htvpyn:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htmv5z:</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="2252">Storage NYC 2018-05-07</customfieldvalue>
    <customfieldvalue id="2320">Storage NYC 2018-05-21</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|htvc6v:</customfieldvalue>

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