[SERVER-28035] Debian Jessie systemd service not handled correctly Created: 17/Feb/17  Updated: 05/Dec/22  Resolved: 16/Nov/22

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: 3.2.9, 3.4.2
Fix Version/s: 4.1 Desired

Type: Bug Priority: Major - P3
Reporter: franck cauvet Assignee: [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
Resolution: Won't Do Votes: 1
Labels: sdp-backlog-purge
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File deinstall.txt     Text File install.txt    
Issue Links:
Duplicate
is duplicated by SERVER-28027 mongod service keeps running even aft... Closed
Assigned Teams:
Server Development Platform
Operating System: ALL
Steps To Reproduce:

Installation :
Fresh install of Debian jessie

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get install -y mongodb-org
mongo

See attachment file install.txt.

Deinstallation : (whith mongo manualluy enabled) :

sudo systctl enable mongod.service
sudo systemctl enable mongod.service
sudo systemctl start mongod.service
mongo
sudo apt-get remove --purge mongodb-org-server
mongo

See attachement file deinstall.txt

Participants:

 Description   

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 (2.7.0.2-5) ...
user@sandbox:~$ mongo
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
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.



 Comments   
Comment by Iryna Zhuravlova [ 16/Nov/22 ]

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

Comment by franck cauvet [ 15/Mar/17 ]

Hi Mark,
Thank you for your feedback.
I keep an eye on this issue.

Regards.
F.

Comment by Mark Agarunov [ 14/Mar/17 ]

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

Comment by Mark Agarunov [ 17/Feb/17 ]

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

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