[SERVER-21321] daemon script pid parse issue Created: 05/Nov/15  Updated: 06/Nov/15  Resolved: 06/Nov/15

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Linda Xu Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-21209 PIDFILEPATH computation in init scrip... Closed
Operating System: ALL
Participants:

 Description   

/etc/init.d/mongod

Here is the line from parse PIDFILEPATH

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

The default configure file come from rpm /etc/mongod.conf for pid is

  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

When daemon parse PIDFILEPATH from configure file, it get the comment line too.

Now the issue is
pid file be created by mongo using the configure/option file, which support "#".
Daemon use PIDFILEPATH parse trying to get some pid file to find pid and kill. It got incorrect file name and cannot kill mongod for clean shutdown.

What user saw is using standard systemctl stop mongod.service or service stop mongod, prompt will return OK but cannot stop mongod.,



 Comments   
Comment by Ramon Fernandez Marina [ 06/Nov/15 ]

lxu, this issue was reported in SERVER-21209, which has already been fixed. Thanks for taking the time to report it and also for providing an elegant solution. The fix will be included in 3.0.8 and 3.2.0-rc3.

Regards,
Ramón.

Comment by Linda Xu [ 05/Nov/15 ]

Parse result on default /etc/mongod.conf

 
[root@ ~]# awk -F'[:=]' -v IGNORECASE=1 '/^[[:blank:]]*(processManagement\.)?pidfilepath[[:blank:]]*[:=][[:blank:]]*/{print $2}' "/etc/mongod.conf" | tr -d "[:blank:]\"'"
/var/run/mongodb/mongod.pid#locationofpidfile

Fix is easy to modify the daemon script to use # as column split
awk -F '[:=]' CHANGE TO awk -F '[:=|#]'

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

Generated at Thu Feb 08 03:56:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.