[SERVER-17977] Removal / Upgrade fails on Debian / Ubuntu in combination with WiredTiger storage engine Created: 10/Apr/15  Updated: 23/Apr/15  Resolved: 23/Apr/15

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

Type: Bug Priority: Major - P3
Reporter: Ronald Feicht Assignee: Unassigned
Resolution: Done Votes: 0
Labels: build-planning
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to DOCS-5269 Mention packaging requirements on con... Closed
Operating System: ALL
Steps To Reproduce:

Install MongoDB 3.0.1 change to WiredTiger storage engine - which means you have to switch to the yaml style configuration.
run

apt-get update && apt-get upgrade mongodb-org

will result in the following error:

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)

Participants:

 Description   

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.



 Comments   
Comment by Ronald Feicht [ 13/Apr/15 ]

Yes, removing the 'fork:true' solves the issue. Thank you very much.

You might want to consider changing what is written on this page
http://docs.mongodb.org/manual/reference/configuration-options/
so others do not trip over the same problem. (I only copied my configuration from there)

Comment by Ernie Hershey [ 10/Apr/15 ]

scsynergy - I believe the problem is the "fork: true" in your new configuration file, which the init script and upstart configuration expect to be false, as it is in the configuration file distributed with the packages. If you take that out or set "fork: false" does it work better?

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