<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:07:46 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-24916] Only get current working directory (cwd) when necessary</title>
                <link>https://jira.mongodb.org/browse/SERVER-24916</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;The expectation is that, in cases where the cwd isn&apos;t needed (which is the common case), any problem with it should not impact the ability of the server to successfully start.&lt;/p&gt;

&lt;p&gt;For situations where cwd problems can prevent startup, see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-24914&quot; title=&quot;Cannot start mongod from cwd &amp;gt; 1000 bytes long&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-24914&quot;&gt;&lt;del&gt;SERVER-24914&lt;/del&gt;&lt;/a&gt; and &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-24915&quot; title=&quot;getcwd() failure should report errno&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-24915&quot;&gt;&lt;del&gt;SERVER-24915&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;getcwd()&lt;/tt&gt; is called from &lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.3.9/src/mongo/db/server_options_helpers.cpp#L458-L468&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;setupCwd()&lt;/tt&gt;&lt;/a&gt;, which sets &lt;tt&gt;serverGlobalParams.cwd&lt;/tt&gt;.  This variable is only used in two places:&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.3.9/src/mongo/db/mongod_options.cpp#L1025&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Resolving a relative dbpath (when --fork is used)&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.3.9/src/mongo/db/initialize_server_global_state.cpp#L234-L236&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Resolving the logpath (in all cases)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;This means there are situations where a problem with the cwd can inhibit server startup, even though the cwd is utterly irrelevant and never actually used.&lt;/p&gt;

&lt;p&gt;One solution would be to rearrange the code so that:&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;logpath is only resolved if it is relative (same as is done for dbpath)&lt;/li&gt;
	&lt;li&gt;&lt;tt&gt;setupCwd()&lt;/tt&gt;/&lt;tt&gt;getcwd()&lt;/tt&gt; is only called if:
	&lt;ul&gt;
		&lt;li&gt;the dbpath is relative (does not start with &lt;tt&gt;/&lt;/tt&gt;) and {--fork}} is used, and/or&lt;/li&gt;
		&lt;li&gt;the logpath is relative (does not start with &lt;tt&gt;/&lt;/tt&gt;)&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;There are a few ways of doing this, but I think a better fix would be:&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;logpath is only resolved if it is relative (same as is done for dbpath)&lt;/li&gt;
	&lt;li&gt;don&apos;t assert if &lt;tt&gt;getcwd()&lt;/tt&gt; fails
	&lt;ul&gt;
		&lt;li&gt;log a warning instead&lt;/li&gt;
		&lt;li&gt;leave &lt;tt&gt;serverGlobalParams.cwd&lt;/tt&gt; as the empty string&lt;/li&gt;
		&lt;li&gt;then access &lt;tt&gt;serverGlobalParams.cwd&lt;/tt&gt; via a wrapper function which returns it or fasserts if it&apos;s empty&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ol&gt;
</description>
                <environment></environment>
        <key id="298862">SERVER-24916</key>
            <summary>Only get current working directory (cwd) when necessary</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="-1">Unassigned</assignee>
                                    <reporter username="kevin.pulo@mongodb.com">Kevin Pulo</reporter>
                        <labels>
                    </labels>
                <created>Wed, 6 Jul 2016 03:15:32 +0000</created>
                <updated>Thu, 7 Jul 2016 14:11:12 +0000</updated>
                            <resolved>Thu, 7 Jul 2016 14:10:33 +0000</resolved>
                                                                    <component>Internal Code</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="1316691" author="kevin.pulo@10gen.com" created="Thu, 7 Jul 2016 14:09:49 +0000"  >&lt;p&gt;No, that was never the intention.  Situations where the server needs the cwd, but is unable to get it, would still fail immediately at startup.  Situations where the server doesn&apos;t need the cwd, the server would start and run just fine, because it would never notice the problem with cwd (since by definition it isn&apos;t used).&lt;/p&gt;

&lt;p&gt;The motivation was that if the user has specified an absolute dbpath and logpath, then why should the server care what the cwd is?  Or if it&apos;s not able to be known?  It seemed silly to fail to start because something which was apparently never used couldn&apos;t be found.&lt;/p&gt;

&lt;p&gt;Although the two listed places are the only places where serverGlobalParams.cwd are used, there are actually other places which can call getcwd() at later times during the dynamic extent, via boost::filesystem::absolute (without passing in a base dir).  Specifically, in MMAPv1 and FTDC.  Although the referenced paths should always be under the dbpath, which has already been resolved at startup, removing these calls to boost&apos;s absolute() feels needlessly risky (in a practical sense).  All of the possible ways in which getcwd() might fail later during execution indicate some larger problem that the server can&apos;t be expected to continue through.&lt;/p&gt;

&lt;p&gt;There is also the possibility that dynamically linked shared libraries might call getcwd() at any point in time, which would be completely outside the server&apos;s control.&lt;/p&gt;

&lt;p&gt;So, it turns out that the server always needs to know the cwd, and so should fail to start if it can&apos;t be determined &amp;#8212; ie. this ticket is Works As Designed.  Since the cwd is now known to be essential, this very slightly increases the importance of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-24915&quot; title=&quot;getcwd() failure should report errno&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-24915&quot;&gt;&lt;del&gt;SERVER-24915&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="1316581" author="scotthernandez" created="Thu, 7 Jul 2016 12:44:38 +0000"  >&lt;p&gt;So in essence you want the server to start but fail later?&lt;/p&gt;

&lt;p&gt;Doesn&apos;t this &quot;hide&quot; the failure until a potentially worse point, when the server could be active with client requests and then fail due to something which was detectable at startup?&lt;/p&gt;

&lt;p&gt;What use case is there to allow an invalid working directory when starting the server?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="298860">SERVER-24914</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="298861">SERVER-24915</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>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 7 Jul 2016 12:44:38 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        7 years, 31 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_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>kevin.pulo@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            7 years, 31 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>kevin.pulo@mongodb.com</customfieldvalue>
            <customfieldvalue>scotthernandez</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrk3h3:</customfieldvalue>

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

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

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