-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Internal Code
-
None
-
Minor Change
The expectation is that, in cases where the cwd isn't needed (which is the common case), any problem with it should not impact the ability of the server to successfully start.
For situations where cwd problems can prevent startup, see SERVER-24914 and SERVER-24915.
getcwd() is called from setupCwd(), which sets serverGlobalParams.cwd. This variable is only used in two places:
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.
One solution would be to rearrange the code so that:
- logpath is only resolved if it is relative (same as is done for dbpath)
- setupCwd()/getcwd() is only called if:
- the dbpath is relative (does not start with /) and {--fork}} is used, and/or
- the logpath is relative (does not start with /)
There are a few ways of doing this, but I think a better fix would be:
- logpath is only resolved if it is relative (same as is done for dbpath)
- don't assert if getcwd() fails
- log a warning instead
- leave serverGlobalParams.cwd as the empty string
- then access serverGlobalParams.cwd via a wrapper function which returns it or fasserts if it's empty
- related to
-
SERVER-24914 Cannot start mongod from cwd > 1000 bytes long
- Closed
-
SERVER-24915 getcwd() failure should report errno
- Closed