Operational Defect Database

BugZero found this defect 2565 days ago.

MongoDB | 355096

[SERVER-28035] Debian Jessie systemd service not handled correctly

Last update date:


Affected products:

MongoDB Server

Affected releases:



Fixed releases:

4.1 Desired



Hi, On a Debian Jessie fresh install, mongodb service is not enabled with systemd, thus it does not start after installation or boot time. user@sandbox:~$ systemctl list-unit-files --type=service |grep mongo mongod.service disabled The package mongodb-org-server comes with the mongod.service file : dpkg -L mongodb-org-server /. ------8<---------------- /lib /lib/systemd /lib/systemd/system /lib/systemd/system/mongod.service But the postinst script of the package does not call for systemctl to enable this service : #!/bin/sh # postinst script for mongodb # # see: dh_installdeb(1)   set -e   # summary of how this script can be called: # * <postinst> `configure' <most-recently-configured-version> # * <old-postinst> `abort-upgrade' <new version> # * <conflictor's-postinst> `abort-remove' `in-favour' <package> # <new-version> # * <postinst> `abort-remove' # * <deconfigured's-postinst> `abort-deconfigure' `in-favour' # <failed-install-package> <version> `removing' # <conflicting-package> <version> # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package     case "$1" in configure) # create a mongodb group and user if ! getent passwd mongodb >/dev/null 2>&1; then adduser --system --no-create-home mongodb addgroup --system mongodb adduser mongodb mongodb fi   # create db -- note: this should agree with dbpath in mongod.conf mkdir -p /var/lib/mongodb chown -R mongodb:mongodb /var/lib/mongodb   # create logdir -- note: this should agree with logpath in mongod.conf mkdir -p /var/log/mongodb chown -R mongodb:mongodb /var/log/mongodb ;;   abort-upgrade|abort-remove|abort-deconfigure) ;;   *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac   # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts.   # Automatically added by dh_installinit if [ -x "/etc/init.d/mongod" ]; then update-rc.d mongod defaults >/dev/null invoke-rc.d mongod start || exit $? fi # End automatically added section     exit 0 It only tests for the existence of sysvinit script, not for the systemd one. This lead to mongod not running after installation or system reboot on Debian Jessie and perhaps on other systems. You might consider adding the same thing for systemd in the postinst script, like : +if [ -f "/lib/systemd/system/mongod.service" ]; then + systemctl --system daemon-reload >/dev/null || true + systemctl enable mongod.service >/dev/null + systemctl start mongod.service|| exit $? +fi Things are getting worse while removing mongodb-org-server package, the mongod service is not stopped while it is removed : user@sandbox:~$ sudo apt-get remove --purge mongodb-org-server Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: mongodb-org-mongos mongodb-org-shell mongodb-org-tools Use 'apt-get autoremove' to remove them. The following packages will be REMOVED: mongodb-org* mongodb-org-server* 0 upgraded, 0 newly installed, 2 to remove and 22 not upgraded. After this operation, 54.5 MB disk space will be freed. Do you want to continue? [Y/n] (Reading database ... 40192 files and directories currently installed.) Removing mongodb-org (3.4.2) ... Purging configuration files for mongodb-org (3.4.2) ... dpkg: warning: while removing mongodb-org, directory '/var/lib/mongodb' not empty so not removed Removing mongodb-org-server (3.4.2) ... Purging configuration files for mongodb-org-server (3.4.2) ... Processing triggers for man-db ( ... user@sandbox:~$ mongo MongoDB shell version v3.4.2 connecting to: mongodb:// MongoDB server version: 3.4.2 Server has startup warnings: 2017-02-17T15:14:31.249+0100 I STORAGE [initandlisten] 2017-02-17T15:14:31.249+0100 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2017-02-17T15:14:31.249+0100 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] 2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] 2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] 2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-02-17T15:14:31.917+0100 I CONTROL [initandlisten] > The prerm script of the package is lacking the stop action for systemd and manage only sysvinit script : cat prerm #!/bin/sh set -e # Automatically added by dh_installinit if [ -x "/etc/init.d/mongod" ]; then invoke-rc.d mongod stop || exit $? fi # End automatically added section You might add something like this to stop the service and disable it before removing the file /lib/systemd/system/mongod.service (which actually do a broken link on the sytem) : +if [ -f "/lib/systemd/system/mongod.service" ]; then + systemctl stop mongod.service|| exit $? + systemctl disable mongod.service > /dev/null +fi And, actually the postrm script seems to be fine. I have seen this issue on 3.2.9 version and 3.4.2 version of mongodb-org-server package on Debian Jessie. It should affect every version between them. Regards. F.

Top User Comments

JIRAUSER1257562 commented on Wed, 16 Nov 2022 17:08:20 +0000: After a careful backlog refinement, the team decided to close this ticket because of its low priority and limited resource capacity. If you believe that this ticket requires additional attention from the team and should be re-opened, feel free to change the status to "Needs Scheduling" and ping me or @alexander.neben fcauvet commented on Wed, 15 Mar 2017 07:55:14 +0000: Hi Mark, Thank you for your feedback. I keep an eye on this issue. Regards. F. mark.agarunov commented on Tue, 14 Mar 2017 21:57:33 +0000: Hello fcauvet, We've managed to reproduce the behavior you've described and are investigating further. If you would like updates on the progress, please continue to watch this issue. Thanks, Mark mark.agarunov commented on Fri, 17 Feb 2017 18:07:11 +0000: Hello fcauvet, Thank you for the report. We are investigating this issue and will update the ticket with any new information as it becomes available. Thanks, Mark

Additional Resources / Links


BugZero Risk Score

Coming soon



Have you been affected by this bug?


Do you know how much operational outages are costing you?

Understand the cost to your business and how BugZero can help you reduce those costs.


Login to read and write comments.

Have you ever...

had your data corrupted from a