<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:56:24 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-62909] The more databases exist, the longer listDatabases takes</title>
                <link>https://jira.mongodb.org/browse/SERVER-62909</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;MongoDB 4.4.10&lt;/p&gt;

&lt;p&gt;MongoDB Operator&lt;/p&gt;

&lt;p&gt;SSD over NFS (should not be an issue)&lt;/p&gt;

&lt;p&gt;3 nodes @ 8 cores running on GKE&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;1 db -&amp;gt; apprx 300ms&lt;/li&gt;
	&lt;li&gt;10&apos;000 dbs -&amp;gt; approx 7sec&lt;/li&gt;
	&lt;li&gt;20&apos;000 dbs -&amp;gt; approx 20sec&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Not sure if it&apos;s linear or exponential&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="1969328">SERVER-62909</key>
            <summary>The more databases exist, the longer listDatabases takes</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="edwin.zhou@mongodb.com">Edwin Zhou</assignee>
                                    <reporter username="jamoser42@gmail.com">John Moser</reporter>
                        <labels>
                    </labels>
                <created>Mon, 24 Jan 2022 14:34:54 +0000</created>
                <updated>Tue, 5 Apr 2022 19:38:08 +0000</updated>
                            <resolved>Tue, 29 Mar 2022 17:06:32 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="4459033" author="JIRAUSER1261267" created="Tue, 5 Apr 2022 19:38:08 +0000"  >&lt;p&gt;Please ignore the issue - it&apos;s definitely not a MongoDB core issue.&lt;/p&gt;</comment>
                            <comment id="4442513" author="JIRAUSER1257066" created="Tue, 29 Mar 2022 17:06:32 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jamoser42%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;jamoser42@gmail.com&quot;&gt;jamoser42@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;We haven&#8217;t heard back from you for some time, so I&#8217;m going to close this ticket. If this is still an issue for you, please provide additional information and we will reopen the ticket.&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Edwin&lt;/p&gt;</comment>
                            <comment id="4404811" author="JIRAUSER1257066" created="Thu, 10 Mar 2022 20:01:54 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jamoser42%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;jamoser42@gmail.com&quot;&gt;jamoser42@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;We still need additional information to diagnose the problem. If this is still an issue for you, would you please attach the $dbpath/diagnostic.data directory covering the slow database creation as requested by my colleague?&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Edwin&lt;/p&gt;</comment>
                            <comment id="4367568" author="JIRAUSER1261267" created="Tue, 22 Feb 2022 05:06:16 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=dmitry.agranat&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;@dmitry.agranat&lt;/a&gt; - pls hold on and let me retry again.&lt;/p&gt;</comment>
                            <comment id="4361122" author="dmitry.agranat" created="Thu, 17 Feb 2022 12:55:46 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jamoser42%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;jamoser42@gmail.com&quot;&gt;jamoser42@gmail.com&lt;/a&gt;, w/o the requested information, I am not sure how we can help. For general questions w/o data, we encourage you to start by asking our community for help by posting on the &lt;a href=&quot;https://community.mongodb.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;MongoDB Developer Community Forums&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you can provide the requested data, we will be happy to take a look and try to help.&lt;/p&gt;

&lt;p&gt;From a single line provided in the attachment which includes the &lt;tt&gt;listDatabases&lt;/tt&gt;, it looks like you might benefit from using the &lt;tt&gt;nameOnly&lt;/tt&gt; option as mentioned in our &lt;a href=&quot;https://docs.mongodb.com/manual/reference/command/listDatabases/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;documentation&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Optional. A flag to indicate whether the command should return just the database names, or return both database names and size information.&lt;br/&gt;
Returning size information requires locking each database one at a time, while returning only names does not require locking any database.&lt;br/&gt;
The default value is false, so listDatabases returns the name and size information of each database.&lt;/p&gt;&lt;/blockquote&gt;</comment>
                            <comment id="4355224" author="JIRAUSER1261267" created="Tue, 15 Feb 2022 05:35:55 +0000"  >&lt;p&gt;&amp;gt;&amp;gt; This would have also helped us to better understand why you need to create, list, and destroy (as well as how frequent) tens of thousands of databases.&lt;/p&gt;

&lt;p&gt;Again its about creating databases - you can run the above snipped in a for loop with count=100&apos;000. It&apos;s reproducible any time that creation of the first collection of the newly created database is taking more and more time. The reason is that listdatabase takes more and more time to execute (seems dependent of the number of collection) The log file I&apos;ve uploaded shows, that during the creation of the first collection, listdatabase is called.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;=&amp;gt; my request: is it possible to remove that call ? Or has listdatabase been optimized, so it&apos;s execution time is not dependent of the number of total number of collections&lt;/p&gt;</comment>
                            <comment id="4353049" author="JIRAUSER1261267" created="Mon, 14 Feb 2022 12:22:26 +0000"  >&lt;p&gt;@&lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;mailto:dmitry.agranat@mongodb.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;dmitry.agranat@mongodb.com&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://jira.mongodb.org/images/icons/mail_small.gif&quot; height=&quot;12&quot; width=&quot;13&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt; I think you misunderstand the issue here - in the code snippet there is no call to &quot;listdatabases&quot; and still the log (as you can see from the logs I&apos;ve uploaded) you can see it.&lt;/p&gt;

&lt;p&gt;So is there a implied &quot;listdatabases&quot; when creating a database (I am not talking about the mongodb cluster) ? And if yes can this be avoided in the mongodb code ?&lt;/p&gt;

&lt;p&gt;Besides the question why so many databases are created - if you are familiar with multitenancy then it makes totally sense to do it like this.&lt;/p&gt;</comment>
                            <comment id="4352970" author="dmitry.agranat" created="Mon, 14 Feb 2022 11:40:18 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jamoser42%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;jamoser42@gmail.com&quot;&gt;jamoser42@gmail.com&lt;/a&gt;, thanks for providing the code snippet but what we wanted to see is the actual (and historical) impact on your system, under your workload via the &lt;tt&gt;diagnostics.data&lt;/tt&gt;. This would have also helped us to better understand why you need to create, list, and destroy (as well as how frequent) tens of thousands of databases.&lt;/p&gt;</comment>
                            <comment id="4343635" author="JIRAUSER1261267" created="Tue, 8 Feb 2022 21:35:10 +0000"  >&lt;p&gt;Sorry - I am not able to copy diagnostic.data/* to local disk.&lt;/p&gt;

&lt;p&gt;As a side note: The replicaset runs on a 3x8 core (N1)&lt;/p&gt;

&lt;p&gt;With 20k -&amp;gt; listdatabase takes approx 2.5s&lt;br/&gt;
 With 100k -&amp;gt; listdatabase takes &amp;gt; 20s&lt;/p&gt;

&lt;p&gt;Here the code snippet which generated the log:&lt;/p&gt;



&lt;p&gt;MongoDatabase db = mongoClient.getDatabase(tenantId);&lt;br/&gt;
 BasicDBObject command = new BasicDBObject(&quot;createUser&quot;, tenantId).append(&quot;pwd&quot;, myPwd).append(&quot;roles&quot;,&lt;br/&gt;
 Collections.singletonList(new BasicDBObject(&quot;role&quot;, &quot;dbOwner&quot;).append(&quot;db&quot;, tenantId)));&lt;br/&gt;
 db.runCommand(command);&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;MongoDatabase database = mongoClient.getDatabase(tenantId); MongoCollection&amp;lt;Document&amp;gt; collection = database.getCollection(&quot;profile&quot;);&lt;br/&gt;
 collection.insertOne(aProfile);&lt;/p&gt;

&lt;p&gt;MongoDatabase database = mongoClient.getDatabase(tenantId); MongoCollection&amp;lt;Document&amp;gt; collection = database.getCollection(&quot;document&quot;);&lt;br/&gt;
 collection.insertOne(aDocument);&lt;/p&gt;

&lt;p&gt;MongoDatabase database = mongoClient.getDatabase(tenantId); MongoCollection&amp;lt;Document&amp;gt; collection = database.getCollection(&quot;folders&quot;);&lt;br/&gt;
 collection.insertOne(aFolder);&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="4341917" author="JIRAUSER1261267" created="Tue, 8 Feb 2022 14:14:43 +0000"  >&lt;p&gt;@&lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;mailto:dmitry.agranat@mongodb.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;dmitry.agranat@mongodb.com&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://jira.mongodb.org/images/icons/mail_small.gif&quot; height=&quot;12&quot; width=&quot;13&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt; pls hold on, I have to prepare the test setup.&lt;/p&gt;

&lt;p&gt;Log file uploaded&lt;/p&gt;</comment>
                            <comment id="4341840" author="dmitry.agranat" created="Tue, 8 Feb 2022 13:44:34 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jamoser42%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;jamoser42@gmail.com&quot;&gt;jamoser42@gmail.com&lt;/a&gt;, do you have an update for my latest request?&lt;/p&gt;</comment>
                            <comment id="4328060" author="JIRAUSER1261267" created="Tue, 1 Feb 2022 17:10:16 +0000"  >&lt;p&gt;Pls hold on.&lt;/p&gt;</comment>
                            <comment id="4315051" author="dmitry.agranat" created="Wed, 26 Jan 2022 12:20:33 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jamoser42%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;jamoser42@gmail.com&quot;&gt;jamoser42@gmail.com&lt;/a&gt;, In order to better understand the issue and the observed behavior, we&apos;d like to review the logs and diagnostics data.&lt;/p&gt;

&lt;p&gt;I&apos;ve created a secure &lt;a href=&quot;https://amphora.corp.mongodb.com/public/upload/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb2xkZXJfaWQiOiIxNTQ4NzI0OTAyMzAiLCJleHAiOjE2NDU3OTE0NjZ9.lWLWNDUjCIN9CFJ7fX3jwj78CGa-dNu-gcSrA-0_CCQ&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;upload portal&lt;/a&gt; for you. Files uploaded to this portal are hosted on Box, are visible only to MongoDB employees, and are routinely deleted after some time.&lt;/p&gt;

&lt;p&gt;For each node in the replica set spanning a time period that includes the incident, would you please archive (tar or zip) and upload to that link:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;the mongod logs&lt;/li&gt;
	&lt;li&gt;the &lt;tt&gt;$dbpath/diagnostic.data&lt;/tt&gt; directory (the contents are described &lt;a href=&quot;https://docs.mongodb.com/manual/administration/analyzing-mongodb-performance/#full-time-diagnostic-data-capture&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;


</comment>
                            <comment id="4311732" author="JIRAUSER1261267" created="Tue, 25 Jan 2022 11:59:07 +0000"  >&lt;p&gt;It looks like if a new database is created then if a collection is added, that during this action listDatabases() is called. So it&apos;s not me calling the method but the MongoDB code.&lt;/p&gt;

&lt;p&gt;But anyways since there must be calls to listDatabases() everywhere in the MongoDB code, it would be great if this fix could also be included to the MongoDB 4.4 version.&lt;/p&gt;

&lt;p&gt;We have a multi tenancy setup, where each tenants has it&apos;s own db. We are approaching 40k db and creation of a new tenant (=new db) takes now forever. Sometimes even timing out. Everything else works pretty fast.&lt;/p&gt;</comment>
                            <comment id="4311702" author="dmitry.agranat" created="Tue, 25 Jan 2022 11:37:56 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jamoser42%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;jamoser42@gmail.com&quot;&gt;jamoser42@gmail.com&lt;/a&gt;, currently, the &lt;tt&gt;listDatabases&lt;/tt&gt; command takes Database or Collection level MODE_IS locks, the more databases/collections you have, the more time you&apos;ll need to wait for locks. We have fixed this in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-57357&quot; title=&quot;listDatabases should be a lock-free operation like listCollections and listIndexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-57357&quot;&gt;&lt;del&gt;SERVER-57357&lt;/del&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;How often do you need to run this command and what output are you looking for?&lt;/p&gt;</comment>
                            <comment id="4309609" author="JIRAUSER1261267" created="Mon, 24 Jan 2022 16:22:12 +0000"  >&lt;p&gt;As a side note - when creating the first collection of newly created database, it looks like that listDatabases is also called. This makes creation of the (first) collection quite a heavy operation (uses a lot of CPU as well as it takes very long) even if the effective creation of the collection takes a couple of xx miliiseconds.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="1969329">SERVER-62910</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>16.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 25 Jan 2022 11:37:56 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 44 weeks, 1 day 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>jamoser42@gmail.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 44 weeks, 1 day ago
                        </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>dmitry.agranat@mongodb.com</customfieldvalue>
            <customfieldvalue>edwin.zhou@mongodb.com</customfieldvalue>
            <customfieldvalue>jamoser42@gmail.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i0hs8n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i00vwf:</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_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>
                                    <customfieldvalue><![CDATA[dmitry.agranat@mongodb.com]]></customfieldvalue>
        <customfieldvalue><![CDATA[edwin.zhou@mongodb.com]]></customfieldvalue>
    

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

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