<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:59:54 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-2417] race condition between drop and FileAllocator&apos;s work queue under --directoryperdb</title>
                <link>https://jira.mongodb.org/browse/SERVER-2417</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;When running under --directoryperdb, if you drop a database, then there is a&lt;br/&gt;
race condition between the code that deletes the directory, and any request&lt;br/&gt;
for more storage enqueued in the FileAllocator.&lt;/p&gt;

&lt;p&gt;This is what I see in the log file (without my patch for &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2416&quot; title=&quot;inverted conditional maans that FileAllocator::run fails to trap failed open()s&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2416&quot;&gt;&lt;del&gt;SERVER-2416&lt;/del&gt;&lt;/a&gt; applied,&lt;br/&gt;
hence the unexpected form of error messages on allocation failure)&lt;/p&gt;

&lt;p&gt;Tue Jan 25 17:09:13 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn415&amp;#93;&lt;/span&gt; end connection 127.0.0.1:33278&lt;br/&gt;
Tue Jan 25 17:09:13 &lt;span class=&quot;error&quot;&gt;&amp;#91;initandlisten&amp;#93;&lt;/span&gt; connection accepted from 127.0.0.1:33279 #416&lt;br/&gt;
Tue Jan 25 17:09:13 allocating new datafile /export/home/netbanx/var/mongodb/data/db/test_velocity_complex_rules/test_velocity_complex_rules.ns, filling with zeroes...&lt;br/&gt;
Tue Jan 25 17:09:13 done allocating datafile /export/home/netbanx/var/mongodb/data/db/test_velocity_complex_rules/test_velocity_complex_rules.ns, size: 16MB,  took 0.027 secs&lt;br/&gt;
Tue Jan 25 17:09:13 allocating new datafile /export/home/netbanx/var/mongodb/data/db/test_velocity_complex_rules/test_velocity_complex_rules.0, filling with zeroes...&lt;br/&gt;
Tue Jan 25 17:09:13 done allocating datafile /export/home/netbanx/var/mongodb/data/db/test_velocity_complex_rules/test_velocity_complex_rules.0, size: 64MB,  took 0.114 secs&lt;br/&gt;
Tue Jan 25 17:09:13 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn416&amp;#93;&lt;/span&gt; building new index on &lt;/p&gt;
{ _id: 1 }
&lt;p&gt; for test_velocity_complex_rules.transactions&lt;br/&gt;
Tue Jan 25 17:09:13 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn416&amp;#93;&lt;/span&gt; done for 0 records 0secs&lt;br/&gt;
Tue Jan 25 17:09:13 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn416&amp;#93;&lt;/span&gt; insert test_velocity_complex_rules.transactions 152ms&lt;br/&gt;
Tue Jan 25 17:09:13 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn416&amp;#93;&lt;/span&gt; dropDatabase test_velocity_complex_rules&lt;br/&gt;
Tue Jan 25 17:09:13 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn416&amp;#93;&lt;/span&gt; end connection 127.0.0.1:33279&lt;br/&gt;
Tue Jan 25 17:09:13 allocating new datafile /export/home/netbanx/var/mongodb/data/db/test_velocity_complex_rules/test_velocity_complex_rules.1, filling with zeroes...&lt;br/&gt;
Tue Jan 25 17:09:13 warning: posix_fadvise fails /export/home/netbanx/var/mongodb/data/db/test_velocity_complex_rules/test_velocity_complex_rules.1 errno:2 No such file or directory&lt;br/&gt;
Tue Jan 25 17:09:13 posix_fallocate failed: errno:9 Bad file descriptor falling back&lt;br/&gt;
Tue Jan 25 17:09:14 Assertion: 10440:failure creating new datafile; lseek failed for fd -1 with errno: errno:9 Bad file descriptor&lt;br/&gt;
0x500278 0x7e49ff 0x7e523f 0x2b9758095c3f 0x2b97580956bf 0x3b4a80673d 0x3b4a0d3d1d &lt;br/&gt;
 /export/home/netbanx/base/usr/mongodb/bin/mongod(_ZN5mongo11msgassertedEiPKc+0x1c8) &lt;span class=&quot;error&quot;&gt;&amp;#91;0x500278&amp;#93;&lt;/span&gt;&lt;br/&gt;
 /export/home/netbanx/base/usr/mongodb/bin/mongod(_ZN5mongo13FileAllocator12ensureLengthEil+0x34f) &lt;span class=&quot;error&quot;&gt;&amp;#91;0x7e49ff&amp;#93;&lt;/span&gt;&lt;br/&gt;
 /export/home/netbanx/base/usr/mongodb/bin/mongod(_ZN5mongo13FileAllocator6RunnerclEv+0x3bf) &lt;span class=&quot;error&quot;&gt;&amp;#91;0x7e523f&amp;#93;&lt;/span&gt;&lt;br/&gt;
 /usr/lib64/libboost_thread.so.2(_ZNK5boost9function0IvSaINS_13function_baseEEEclEv+0xbf) &lt;span class=&quot;error&quot;&gt;&amp;#91;0x2b9758095c3f&amp;#93;&lt;/span&gt;&lt;br/&gt;
 /usr/lib64/libboost_thread.so.2 &lt;span class=&quot;error&quot;&gt;&amp;#91;0x2b97580956bf&amp;#93;&lt;/span&gt;&lt;br/&gt;
 /lib64/libpthread.so.0 &lt;span class=&quot;error&quot;&gt;&amp;#91;0x3b4a80673d&amp;#93;&lt;/span&gt;&lt;br/&gt;
 /lib64/libc.so.6(clone+0x6d) &lt;span class=&quot;error&quot;&gt;&amp;#91;0x3b4a0d3d1d&amp;#93;&lt;/span&gt;&lt;br/&gt;
Tue Jan 25 17:09:14   Failed to allocate new file: /export/home/netbanx/var/mongodb/data/db/test_velocity_complex_rules/test_velocity_complex_rules.1, size: 134217728, aborting.&lt;/p&gt;

&lt;p&gt;The race is between this code in FileOp:&lt;/p&gt;

&lt;p&gt;    void _deleteDataFiles(const char *database) {&lt;br/&gt;
        if ( directoryperdb ) &lt;/p&gt;
{
            BOOST_CHECK_EXCEPTION( boost::filesystem::remove_all( boost::filesystem::path( dbpath ) / database ) );
            return;
        }

&lt;p&gt;and the loop in FileAllocator::run, and goes badly wrong if the sequence of&lt;br/&gt;
events is&lt;/p&gt;

&lt;p&gt;1: mongod decides to pre-allocate more storage for this database, and enqueues&lt;br/&gt;
   a new file name on the FileAllocator&apos;s pending queue&lt;br/&gt;
2: the client instructs mongod to drop the database, and the server calls&lt;br/&gt;
   _deleteDataFiles() above&lt;br/&gt;
3: the queue runner thread reaches the enqueued name, and attempts to create&lt;br/&gt;
   the file&lt;/p&gt;

&lt;p&gt;At that point the open fails, and the allocator sets the failed status to true,&lt;br/&gt;
and no more allocation is possible.&lt;/p&gt;


&lt;p&gt;I see that in master there is now this code:&lt;/p&gt;

&lt;p&gt;                    ensureParentDirCreated(name);&lt;br/&gt;
                    long fd = open(name.c_str(), O_CREAT | O_RDWR | O_NOATIME, S_IRUSR | S_IWUSR);&lt;/p&gt;

&lt;p&gt;That&apos;s &lt;b&gt;still&lt;/b&gt; a race, albeit a much smaller race. It&apos;s still possible that the&lt;br/&gt;
boost::filesystem::remove_all hits between the two lines above.&lt;/p&gt;

&lt;p&gt;I believe that the only correct race-free solution is for the delete code to&lt;br/&gt;
purge the pending queue of any allocations for this directory about to be&lt;br/&gt;
deleted. I see that this would require a new method added to FileAllocator to&lt;br/&gt;
do this, as the pending queue is private to it.&lt;/p&gt;

&lt;p&gt;Nicholas Clark&lt;/p&gt;</description>
                <environment>Linux</environment>
        <key id="14327">SERVER-2417</key>
            <summary>race condition between drop and FileAllocator&apos;s work queue under --directoryperdb</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="aaron">Aaron Staple</assignee>
                                    <reporter username="nicholas.clark">Nicholas Clark</reporter>
                        <labels>
                    </labels>
                <created>Thu, 27 Jan 2011 14:30:51 +0000</created>
                <updated>Tue, 12 Jul 2016 00:20:01 +0000</updated>
                            <resolved>Mon, 31 Jan 2011 19:57:43 +0000</resolved>
                                                    <fixVersion>1.7.6</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="22884" author="auto" created="Mon, 31 Jan 2011 19:56:04 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;astaple&apos;, u&apos;name&apos;: u&apos;Aaron&apos;, u&apos;email&apos;: u&apos;aaron@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2417&quot; title=&quot;race condition between drop and FileAllocator&amp;#39;s work queue under --directoryperdb&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2417&quot;&gt;&lt;del&gt;SERVER-2417&lt;/del&gt;&lt;/a&gt; wait for file allocator to finish in _deleteDataFiles directoryperdb case&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/e6396979996d107420aa13dbf65232482edb9abc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/e6396979996d107420aa13dbf65232482edb9abc&lt;/a&gt;&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>1.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 Jan 2011 15:50:37 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        13 years, 3 weeks, 2 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>
                            13 years, 3 weeks, 2 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="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aaron</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>nicholas.clark</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrp7un:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>20724</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|ht0so7:</customfieldvalue>

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