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

Unable to start mongod service when omiting pidfilepath in mongod.conf

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.2.10
    • Fix Version/s: 3.4.0-rc1
    • Component/s: Packaging
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v3.2
    • Steps To Reproduce:
      Hide

      1. Populate a file named test.conf with yaml that does not contain a reference to pidfilepath:

      > cat test.conf
      storage:
          dbPath: /mnt/data/mongo3
          directoryPerDB: true
          engine: wiredTiger
          journal:
              enabled: true
       
      systemLog:
          logAppend: true
          quiet: false
          destination: syslog
       
      processManagement:
          fork: true
       
      security:
          keyFile: /etc/mongo.key
       
      replication:
          replSetName: testrepl
       
      setParameter:
          logUserIds: 1
      

      2. Set the config file

      > CONFIGFILE="test.conf"
      

      3. Parse the pidfilepath

      > PIDFILEPATH=`awk -F'[:=]' -v IGNORECASE=1 '/^[[:blank:]]*(processManagement\.)?pidfilepath[[:blank:]]*[:=][[:blank:]]*/{print $2}' "$CONFIGFILE" | tr -d "[:blank:]\"'" | awk -F'#' '{print $1}'`
      

      4. Run the check

      if [ -f $PIDFILEPATH ]; 
           then echo "Error starting mongod. $PIDFILEPATH exists." 
           RETVAL=1 
           return 
      fi
      

      5. Observe that the statement erroneously evaluates to true.

      Show
      1. Populate a file named test.conf with yaml that does not contain a reference to pidfilepath: > cat test.conf storage: dbPath: /mnt/data/mongo3 directoryPerDB: true engine: wiredTiger journal: enabled: true   systemLog: logAppend: true quiet: false destination: syslog   processManagement: fork: true   security: keyFile: /etc/mongo.key   replication: replSetName: testrepl   setParameter: logUserIds: 1 2. Set the config file > CONFIGFILE="test.conf" 3. Parse the pidfilepath > PIDFILEPATH=`awk -F'[:=]' -v IGNORECASE=1 '/^[[:blank:]]*(processManagement\.)?pidfilepath[[:blank:]]*[:=][[:blank:]]*/{print $2}' "$CONFIGFILE" | tr -d "[:blank:]\"'" | awk -F'#' '{print $1}'` 4. Run the check if [ -f $PIDFILEPATH ]; then echo "Error starting mongod. $PIDFILEPATH exists." RETVAL=1 return fi 5. Observe that the statement erroneously evaluates to true.
    • Sprint:
      Build 2016-10-31

      Description

      File: init.d-mongod

      The problem occurs when the contents of the $CONFIGFILE does not contain a reference to pidfilepath. In this case, the parsing results in a null string value for PIDFILEPATH. The if-statement that uses PIDFILEPATH does not quote the variable and so the if-statement will evaluate to true even though there is obviously no such 'null' file.

      This was observed when running

      service mongod start
      

      resulting in the error

      Error starting mongod.  exists.
      

      Surrounding the PIDFILEPATH in quotes should fix the problem:

      if [ -f "$PIDFILEPATH" ];
      then echo "Error starting mongod. $PIDFILEPATH exists."
      RETVAL=1
      return
      fi

      The documentation states that the pidfilepath is not required: "Without a specified processManagement.pidFilePath option, the process creates no PID file."

      Appears to be resulting from the changes made in SERVER-12048

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: