[ZBX-16078] Zabbix hangs at shutdown Created: 2019 May 03 Updated: 2024 Aug 03 Resolved: 2019 Aug 12 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Incident report | Priority: | Trivial |
Reporter: | Franky Van Liedekerke | Assignee: | Andrei Gushchin (Inactive) |
Resolution: | Won't fix | Votes: | 3 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: |
![]() |
Description |
When rebooting the zabbix server (redhat 7.6, systemd), the server hangs on zabbix shutdown: "a stop job is running for Zabbix Server" Relevant rpm package info: zabbix-server-pgsql-4.2.1-1.el7.x86_64 Since the server was patched beforehand (yum update), could that have triggered this (a second reboot didn't cause this)? Because that would mean zabbix needs to be shut down manually before patching begins. |
Comments |
Comment by Vladislavs Sokurenko [ 2019 May 03 ] |
Could you please be so kind and show output of "ps -ax | grep zabbix" ? |
Comment by Andrei Gushchin (Inactive) [ 2019 May 03 ] |
Anything in the zabbix_server.log? How long does it take? |
Comment by Franky Van Liedekerke [ 2019 May 04 ] |
ps is impossible, since the server was shutting down (no login was possible anymore). I checked /var/log/messages and php/apache logs and found nothing, I'll check zabbix_server.log on Monday. But the question on how long it took: forever, it did not end anymore (I needed a hard reset to recover). |
Comment by Franky Van Liedekerke [ 2019 May 04 ] |
Btw: I need to check it, but it seems the systemd timeout when stopping the service was set to forever. Maybe T{{imeoutStopSec could help.}} |
Comment by Andrei Gushchin (Inactive) [ 2019 May 07 ] |
Thank you. Are zabbix server pid defined properly in systemd service file? |
Comment by Franky Van Liedekerke [ 2019 May 07 ] |
The systemd file is the one provided by the zabbix rpm by default:
Like I said: on normal startup, it works fine. But these messages show at boot:
The 2 failure lines are at shutdown, the third pid-issue at startup. Taking this into account, I think the zabbix service file can use some improvements. (just suggesting here). |
Comment by richlv [ 2019 May 07 ] |
TimeoutSec=0 is used to avoid nuking server process during the DB upgrade. |
Comment by Franky Van Liedekerke [ 2019 May 07 ] |
While I can believe this to be true at startup, it can't be the case at shutdown. So then you should use TimeoutStartSec=0 |
Comment by richlv [ 2019 May 07 ] |
It is in particular important for shutdown - let's say server starts up, DB upgrade is started. While it is in progress, Zabbix server process is stopped. This would leave the DB in a broken state. |
Comment by Franky Van Liedekerke [ 2019 May 07 ] |
While the process is starting up, it should not mark itself as started, that way a shutdown will not happen until the process has completed the startup. The correct method of doing that in systemd is using type=notify and using notifying systemd when all is finished, e.g.: https://www.freedesktop.org/software/systemd/man/systemd-notify.html
|
Comment by Matt Stephenson [ 2019 Aug 11 ] |
On Ubuntu 18.04.3 with zabbix-server-mysql 4.0.11-1+bionic, I get this behaviour at every reboot of the server. This is caused by MySQL being shutdown before Zabbix Server, causing the log to be continually filled with MySQL connection attempts until systemd eventually times out and forces a shutdown/reboot. Log:- |
Comment by Vladislavs Sokurenko [ 2019 Aug 11 ] |
mattstephenson Zabbix server cannot shut down without a working database as history syncers need to sync data to the database |
Comment by Marek Krolikowski [ 2019 Aug 11 ] |
Same problem here with 4.0.11 on Debian 10: root@zabbix:~# dpkg -l |grep zabbix
And same like other ppl i can`t login via SSH or console. Best regards TaKeN |
Comment by Vladislavs Sokurenko [ 2019 Aug 11 ] |
could you please show contents of zabbix unit file that is used by systemd ? |
Comment by Vladislavs Sokurenko [ 2019 Aug 11 ] |
As richlv mentioned originally reported issue could be caused by But new reports might be about another issue, it is possible that systemd for some reason stops MySQL server first and then try to stop Zabbix server, however Zabbix server depends on MySQL server and it should always be stopped before MySQL is stopped, otherwise history cannot be synced reliably . |
Comment by Matt Stephenson [ 2019 Aug 11 ] |
Unit file has no mention of MySQL
[Unit] [Service] [Install] |
Comment by Marek Krolikowski [ 2019 Aug 11 ] |
i got exacly same like mattstephenson root@zabbix:~# md5sum /lib/systemd/system/zabbix-server.service root@zabbix:~# cat /lib/systemd/system/zabbix-server.service [Service] [Install]
Best Regards TaKeN |
Comment by Vladislavs Sokurenko [ 2019 Aug 11 ] |
Thanks, I think that optional dependency on MySQL server must be added there |
Comment by Vladislavs Sokurenko [ 2019 Aug 12 ] |
As for the second part of the issue this is duplicate of |
Comment by Vladislavs Sokurenko [ 2019 Aug 12 ] |
Closing this as Won't Fix as originally reported issue resolved itself after upgrade was complete |
Comment by Goran [ 2024 Aug 01 ] |
The default settings in 2024 also makes it hang if mysql service is down. I didn't think to restert mysql before I powered off the server forcefully so I lost about 6 hours of logs.
[Unit] [Service] [Install] |
Comment by Matt Stephenson [ 2024 Aug 01 ] |
I still experience this.. so I have in place a systemd override..
[Unit] |
Comment by Goran [ 2024 Aug 01 ] |
Thanks, I'll try that. I don't understand systemd that well. What does that line do. I thought that was for when it boots? Will that actually start or restart mysql if it's down on boot? And also I guess it will do it when machine is rebooting and if mysql is down before zabbix it will restart mysql and then zabbix can go down, and later also mysql.
Well I couldn't get the override to work with systemctl edit zabbix-server. No changes show up when i do systemctl cat zabbix. Now I have to learn how to edit systemd files |
Comment by Matt Stephenson [ 2024 Aug 02 ] |
I just make a file at: /etc/systemd/system/zabbix-server.service.d/override.conf With contents:- [Unit] Restart server and this seems to make everything start/shutdown in the correct order.
|
Comment by Goran [ 2024 Aug 02 ] |
Awesome thanks. I did 'systemctl edit mysql' by accident and the override.conf file was created for mysql.service instead. It works now. I tested by stopping mysql and then rebooted. |
Comment by Marek Krolikowski [ 2024 Aug 02 ] |
Since Zabbix 4.0, I have been using my own entries for systemctl and haven't had any issues. When setting up Zabbix for a client, I didn't create these entries, and the problem still occurs even in version 6.0. I don't quite understand why this BUG was closed if it still persists. Here are the entries I have in systemctl: root@zabbix:~# systemctl edit zabbix-server [Unit] Description=Zabbix Server Wants=mariadb.service After=mariadb.service After=syslog.target After=network.target Wants=mysql.service After=mysql.service Wants=postgresql.service After=postgresql.service |
Comment by Matt Stephenson [ 2024 Aug 02 ] |
TaKeN I completely agree - I am using version 6.0 also. Surely this must be affecting more users of Zabbix Server/Proxy. |
Comment by Marek Krolikowski [ 2024 Aug 02 ] |
In the default file /lib/systemd/system/zabbix-server.service, developers should add the Wants= lines in addition to the lines starting with After=. |
Comment by Goran [ 2024 Aug 03 ] |
I guess the reason is we can't depend on mysql service for 2 reasons:
https://support.zabbix.com/browse/ZBX-15602
That being said. I don't really know what exactly 'Wants' does so I might be completely missing the point. I've read the manual what Wants is, but I don't really have experience with this. |
Comment by Matt Stephenson [ 2024 Aug 03 ] |
I am no expert in systemd either, but i use "Requires" because this is a 'hard dependency', where stopping MySQL, will stop Zabbix too (Zabbix cannot be running without MySQL). "Wants" by comparison is a 'soft dependency', Zabbix will start MySQL (if not already started), however stopping MySQL will allow Zabbix to keep running. |