-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.0.1, 3.0.2
-
Component/s: Packaging
-
ALL
-
First off, installing mongodb-org (3.0.1) worked without errors on
Distributor ID: Debian
Description: Debian GNU/Linux 7.8 (wheezy)
Release: 7.8
Codename: wheezy
and
Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise
Since I wanted to test the WiredTiger engine I had to change the configuration file format to yaml:
root@debian:/etc# cat mongod.conf
systemLog:
destination: file
path: "/var/log/mongodb/mongodb.log"
logAppend: true
storage:
dbPath: "/var/lib/mongodb"
engine: wiredTiger
journal:
enabled: true
processManagement:
fork: true
net:
bindIp: 127.0.0.1
port: 27017
setParameter:
enableLocalhostAuthBypass: true
Now, the start script /etc/init.d/mongod fails because the PID it saves to
cat /var/run/mongod.pid
10142
is wrong - that PID does not exist.
And since the dpkg post-install and prerm scripts try to start / stop mongod they will fail and therefor any removal or upgrade to MongoDB 3.0.2 must also fail:
Unpacking replacement mongodb-org ...
Processing triggers for man-db ...
Setting up libdpkg-perl (1.16.16) ...
Setting up dpkg-dev (1.16.16) ...
Setting up mongodb-org-shell (3.0.2) ...
Setting up mongodb-org-server (3.0.2) ...
[FAIL] Starting database: mongod failed!
invoke-rc.d: initscript mongod, action "start" failed.
dpkg: error processing mongodb-org-server (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up mongodb-org-mongos (3.0.2) ...
Setting up mongodb-org-tools (3.0.2) ...
dpkg: dependency problems prevent configuration of mongodb-org:
mongodb-org depends on mongodb-org-server; however:
Package mongodb-org-server is not configured yet.dpkg: error processing mongodb-org (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mongodb-org-server
mongodb-org
E: Sub-process /usr/bin/dpkg returned an error code (1)
Luckily, I was able to get a screenshot of what goes wrong:
# ps -ef | grep mongodb
root 9951 2 0 08:49 ? 00:00:00 [kworker/1:1]
mongodb 10142 1 0 08:51 ? 00:00:00 /usr/bin/mongod --config /etc/mongod.conf
mongodb 10144 10142 0 08:51 ? 00:00:00 /usr/bin/mongod --config /etc/mongod.conf
mongodb 10145 10144 12 08:51 ? 00:00:04 /usr/bin/mongod --config /etc/mongod.conf
root 10206 4584 0 08:52 pts/1 00:00:00 ps -ef
root@debian:/var/lib# kill 10142
bash: kill: (10142) - No such process
When using a yaml style config file and the WiredTiger storage engine the MongoDB init script starts a process whose PID is written to /var/run/mongod.pid. This process then starts the real mongod and terminates itself so that the PID inside /var/run/mongod.pid is now defunct.
An easy workaround is to edit the init script and paste these two lines into /etc/init.d/mongod:
start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
--make-pidfile --chuid $DAEMONUSER \
--exec $NUMACTL $DAEMON $DAEMON_OPTS
errcode=$?
######## next two lines added by scsynergy
sleep 5
ps -ef | grep mongodb | grep -v grep | awk '{print $2}' > $PIDFILE
We now save the correct PID to file and starting / stopping works - but it is not a pretty solution, just a workaround hack which needs to be improved.