Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-24916

Only get current working directory (cwd) when necessary

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Internal Code
    • None
    • Minor Change

    Description

      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:

      1. Resolving a relative dbpath (when --fork is used)
      2. Resolving the logpath (in all cases)

      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:

      1. logpath is only resolved if it is relative (same as is done for dbpath)
      2. 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:

      1. logpath is only resolved if it is relative (same as is done for dbpath)
      2. 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

      Attachments

        Activity

          People

            Unassigned Unassigned
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: