[SERVER-16240] RHEL sysvinit script causes error on el6.6 Created: 19/Nov/14  Updated: 09/Feb/15  Resolved: 19/Nov/14

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Jakov Sosic Assignee: Ramon Fernandez Marina
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-16081 init.d mongod startup script fails, w... Closed
Related
Operating System: ALL
Steps To Reproduce:

1) upgrade RHEL/CentOS/Scientific to 6.6
2) /etc/init.d/mongod start

Participants:

 Description   

Mongo 2.6.x sysv init script for EL6 isn't working correctly on 6u6. This is the output that standard start call returns:

# /etc/init.d/mongod restart                                                                                                                                                           
Stopping mongod:                                           [  OK  ]
Starting mongod: /usr/bin/dirname: extra operand `2>&1.pid'
Try `/usr/bin/dirname --help' for more information.
                                                           [  OK  ]

Problem is that RedHat changed /etc/rc.d/init.d/functions, in a way that function __pids_var_run() contains new entry:

        local pid_dir=$(/usr/bin/dirname $pid_file)

This is wrongly interpreted in daemon() function that Mongo uses. Problem is that $base is considered complete line:

"$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"

This causes side effect:

+ base='null 2>&1'
+ __pids_var_run 'null 2>&1' '' 
+ local 'base=null 2>&1'
+ local 'pid_file=/var/run/null 2>&1.pid'
++ /usr/bin/dirname /var/run/null '2>&1.pid'
/usr/bin/dirname: extra operand `2>&1.pid'
Try `/usr/bin/dirname --help' for more information.
+ local pid_dir=

and thus spitting out errors.

Solution is to use '--check' parameter for daemon() call. Here is proposing patch:

--- /etc/init.d/mongod  2014-10-08 10:29:50.000000000 -0700
+++ /tmp/mongod.patched 2014-11-19 10:42:41.000000000 -0800
@@ -27,6 +27,7 @@
 PIDDIR=`dirname $PIDFILE`
 
 mongod=${MONGOD-/usr/bin/mongod}
+servicename=mongod
 
 MONGO_USER=mongod
 MONGO_GROUP=mongod
@@ -63,7 +64,7 @@
   ulimit -u 32000
 
   echo -n $"Starting mongod: "
-  daemon --user "$MONGO_USER" "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"
+  daemon --check $servicename --user "$MONGO_USER" "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"
   RETVAL=$?
   echo
   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod



 Comments   
Comment by Ramon Fernandez Marina [ 21/Dec/14 ]

smowtion, note also there's a possible workaround posted in SERVER-16081. The workaround was successfully tested by another user.

Comment by Daniel Pasette (Inactive) [ 21/Dec/14 ]

The work is being tracked in the duplicate issue: SERVER-16081. It is currently scheduled for the next release candidate.

Comment by Smowtion [ 21/Dec/14 ]

Hello, What's happen? I have same issue and can't start mongodb ? What's solution for that ?

Comment by Ramon Fernandez Marina [ 19/Nov/14 ]

No problem jsosic@neogov.net, some times is not easy to find if something has been reported before. Thanks for taking the time to open a detailed ticket, and specially for putting together a tentative patch!

Comment by Jakov Sosic [ 19/Nov/14 ]

Sorry, didn't found other bug...

Comment by Ramon Fernandez Marina [ 19/Nov/14 ]

Thanks for your report jsosic@neogov.net, and for the proposed patch. This issue was recently reported in SERVER-16081, so I'm closing it as a duplicate.

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