[Pkg-dns-devel] Bug#892914: reload hangs with systemd

Vincent Bernat bernat at debian.org
Wed Mar 14 12:47:24 UTC 2018


Source: unbound
Version: 1.6.7-1
Severity: normal
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hey!

The systemd integration is a bit buggy with reload. On reload, unbound
will send STOPPING=1 then READY=1. After STOPPING=1 is sent, the
unbound-control process terminates. When receiving SIGCHLD, systemd
looks at the situation and transforms the "reload" state into a
"stop-sigterm" because of the STOPPING=1 notification previously sent:

Mar 14 13:07:54 infra-msg-pp002 systemd[1]: unbound.service: Child 13883 belongs to unbound.service
Mar 14 13:07:54 infra-msg-pp002 systemd[1]: unbound.service: Control process exited, code=exited status=0
Mar 14 13:07:54 infra-msg-pp002 systemd[1]: unbound.service: Got final SIGCHLD for state reload.
Mar 14 13:07:54 infra-msg-pp002 systemd[1]: unbound.service: Changed reload -> stop-sigterm

In this state, systemd waits for unbound to terminate. After a few
minutes, it will send SIGKILL to forcibly kill unbound. Attached is a
patch fixing this situation. I would be grateful if you could also
forward it upstream.

Thanks!

- -- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (101, 'experimental-debug'), (101, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.15.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-----BEGIN PGP SIGNATURE-----

iQJGBAEBCAAwFiEErvI0h2bzccaJpzYAlaQv6DU1JfkFAlqpGdwSHGJlcm5hdEBk
ZWJpYW4ub3JnAAoJEJWkL+g1NSX5IpkP/3uEPxdnCunRWFTHq9GVY459vseoQZ8d
Yk/tvlhk0l1N8IxYgo/bMsWN3ri4MNNCBPHmfSqN+DS3wOVo1dzhyG4g7hv7DL7P
2TwphKFZGvtefRWKHoYL13aamEfvCiiOm/OARwavJL1ZTh7CcnIOIHYHmLy0cz91
SeE3PH0dGRMgaVWE5MqzoO53H0RwmDerMdekn4pzrPusytiThA1gPO/YclVl4kdP
CGnJvee/i2CnTpcp+RTBNaNFkg5MpIIHj0vrJP/+JPE4/hPyzGYH7na7YCB9b137
4pQKAwehXbWR2Q9YPqS/C1EZRO+mvGd2bgdfwymsgj/Dm6MlVSPv3eNWxCtPz3s6
7f39j/fyW4TqMQ4ohRJB2tliRDqFI03e6IVnpRHJy76887Uw+2JNXble+yn+lBFi
0+sxozRZvna8WhowbflOhA7llSBzCOp/dy5b6QBmexgu1kSzs/QbzxAxYJ7o8Zds
7Y/vPcFDUjy5noDI15icZkdjvDZ7OtenLnWnQoHshUj6XR/PvUwBqbQrS3UlcxMr
G/LdI11FWnehLLHLcPzd9Dy2P4hCScrkBNHPsQaXuvRP58+39PKM55nSkobkeXAx
pjyG7QK0WwGttmJaqE/5S/tb60ea87i94VxK04Mbs0J5Cv/J2fRTIpTHy34Pvtua
HnGhOx04fOCi
=zuLx
-----END PGP SIGNATURE-----
-------------- next part --------------
Do not send status update with STOPPING=1 during reload. Otherwise,
systemd may transition from reload to stop-sigterm because of this.

Index: unbound-1.6.7/daemon/daemon.c
===================================================================
--- unbound-1.6.7.orig/daemon/daemon.c
+++ unbound-1.6.7/daemon/daemon.c
@@ -650,7 +650,10 @@ daemon_fork(struct daemon* daemon)
 	log_info("start of service (%s).", PACKAGE_STRING);
 	worker_work(daemon->workers[0]);
 #ifdef HAVE_SYSTEMD
-	sd_notify(0, "STOPPING=1");
+	if (daemon->workers[0]->need_to_exit)
+		sd_notify(0, "STOPPING=1");
+	else
+		sd_notify(0, "RELOADING=1");
 #endif
 	log_info("service stopped (%s).", PACKAGE_STRING);
 


More information about the pkg-dns-devel mailing list