[MDEV-14944] Systemd mysql service unit (alias) reported as inactive while it should be reported as active Created: 2018-01-14 Updated: 2021-09-16 Resolved: 2021-09-16 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Platform Debian |
| Affects Version/s: | 10.1.26 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Laurent Declercq | Assignee: | Axel Schwenke |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | systemd | ||
| Environment: |
No LSB modules are available. |
||
| Description |
|
Under Debian Stretch, the MariaDB server comes with the mariadb service unit:
The mysql and mysqld service units are also provided as aliases (alternative names):
In our environment we have a cron task that is responsible to renew our let's encrypt SSL certificates. That cron task check that the mysql service is running prior doing anything else and exit if the service is not running. We execute the following command to check the service:
Lately, one of our certificate has not been renewed. After some investigation, we have found that the command above report the mysql service as inactive while it is active. However, the same command on the mariadb service unit report the service as active. Executing the systemctl status mysql command seem to solve the problem because when re-running the systemctl is-active mysql command just after, the service is reported as active. That is really a weird issue. |
| Comments |
| Comment by Laurent Declercq [ 2018-01-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
The issue can be reproduced has follows: 1. Start the mariadb service:
2. Check that the service is running:
3. Enable the mariadb service unit. This is what our installation script is doing to ensure that the service is enabled. Basicallyn it resolves the aliased mysql unit to the real mariadb.service unit and enable it):
4. Check status of aliased service units:
As you can see, both are reported as inactive while we expect them reported as active. Now the weird part: 5. Check terce status of aliased units:
So here both are showed as active (running)
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Laurent Declercq [ 2018-01-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2018-01-24 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Does systemctl disable ... ever occur in your scenario? It should probably be happening at some point, if you have to run enable every time, right? From the beginning of systemd support, we have had the problem described in | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Laurent Declercq [ 2018-01-24 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hey Elena, We are providing a software (control panel for shared hosting environment management) which provides many server implementations, including a MariaDB server implementaton. On setup, the installation routines from our MariaDB server implementation make sure that the service is enabled by simply running: systemctl enable mariadb.service . See:
Problem is that once you done that, the mysql.service unit, which is an alias of the mariadb.service unit will be reported as inative because not pre-loaded, and this, even if the mariadb.service is active (server running). This is a bit annoying for scripts that are relying on the mysql.service unit for compatibility purpose. Basically, an alias unit should be always reported as active if the service that define it is active. That is not the case currently. The bug has been lately confirmed by Lennart Poettering (systemd). We solved that issue in our systemd provider by resolving the unit first (mysql.service -> mariadb.service) but. from my point of view, you should simply drop the mysql.service and mysqld.service aliases, and rename the mysql sysvinit script to mariadb. Ondřej Surý already said me that you wanted get ride of those aliases. See https://twitter.com/nuxwin/status/955536106971418624 I hope that my explanation are clear enough now. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2018-01-26 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm not sure that oerdnj is planning to do it in 10.1, but since Debian guys generally decide on our debian packaging issues, I'm assigning it to oerdnj to handle. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2018-01-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
As systemd service definitions are a shared resource input from other distros is important. mschorm do you have an opinion of systemd aliases here? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2018-01-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
FYI systemd developers have corrected the discrepancy in is-active resulting from aliases https://github.com/systemd/systemd/pull/7997 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michal Schorm [ 2018-01-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
TL;DR: L;R: However I'm still not convinced it is the right thing to do, if somebody really wants it, they can always edit the init file. But on the other hand, I have no idea, how popular such usecase is. — AFAI understand, systemd fixed that, so now we only talk about a workaround, till the new systemd version finds its way to the OSs, right? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Laurent Declercq [ 2018-01-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Good luck to find a workaround for the systemd behavior prior the fix... Units that are not referenced are not pre-loaded, hence the wrong behavior. Those systemd aliases are provided for compatibility purpose right? That is, one administrator and older backend tools (such as those provided by our own software) can continue relying on mysql service name to act on the SQL service without having to known the vendor (MariaDB or MySQL). The problem with systemd unit aliases is that those are not really aliases. I had a hard discussion lately with Lennart Poettering regarding the alias definition. From my point of view when you act on an alias, the behavior should remain same as if you act on the unit that define that alias. Unfortunately, that is not currently the case. See the https://github.com/systemd/systemd/issues/7874 issue for futher understanding. That is why I think that providing those aliases can lead to confusion and unexpected behavior (from end-users point of view) because acting on them is not transparent. Think of the case where you have an unit defining an alias and then, you try to enable the service using the alias instead of the real unit. Here, if the real unit is already enabled, systemd will fails miserably while we could expect a NOOP (command status 0) like that is the case when you try to enable an unit which is already enabled. That why I did recommend to remove those aliases and force administrators and tool's maintainers to operate on real service name. Sometime, we need go ahead. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michal Schorm [ 2018-01-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Laurent Declercq We understand each other. Just the "workaround" wasn't the correct term. A "fix till that time" would be appropriate. The removal of those aliases - either for good or till systemd fix reach OSs - sound's like a reasonable solution to me. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2018-01-30 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Other notes while I think of them: Distro's installing links in /etc/systemd/system/ seems the wrong place to do it. Seems like this was meant to be user configurable space only. If these weren't created by systemd this would seems like a good way to confuse aliases too. When I added the aliases in the first systemd definitions for mariadb I was just loosely following what was possible/suggested/elsewhere. I don't have a great overwhelming story apart from a vague concept that other services depending on the alias rather than an implementation. Interesting read of the meaning of Aliases in the github issue. Thanks for getting to a point of clarity. For users to add a dependency on mariadb they can override /etc/systemd/system/YYY.service.d/XXXX.conf and add [Unit]..After=mariadb.service and the rest of the configuration will be based on the YYY.service will come from the system definition. They could add a mariadb alias in a similar way if they wanted and that would be better than editing the init file. Adding a https://mariadb.com/kb/en/library/systemd/ section on this with the lessons learnt from this MDEV would be useful if aliases are discussed in any meaningful way. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2019-04-10 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
might be the same as | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Axel Schwenke [ 2021-09-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
This affects an old version of the server (10.1). If this problem persists with an up-to-date version, please open a new ticket. |