[MDEV-19226] Add EnvironmentFile=/etc/sysconfig/mariadb to MariaDB service's unit file Created: 2019-04-10  Updated: 2021-03-03  Resolved: 2021-03-03

Status: Closed
Project: MariaDB Server
Component/s: Packaging
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Valerii Kravchuk Assignee: Alexey Bychko (Inactive)
Resolution: Won't Fix Votes: 0
Labels: systemd


 Description   

It's normal and expected for systemd services to provide a way to set environment variables without direct modification of the servic's until file (that may be lost during upgrade etc). In case of gardb it's done via /etc/sysconfig/garb, in case of MySQL server it's /etc/sysconfig/mysql, see https://dev.mysql.com/doc/refman/8.0/en/using-systemd.htm.

For some reason MariaDB service's unit file included with RPMs for CentOS 7 etc does NOT contain any predefined EnvironmentFile setting. I think it should be added, so service reads whatever definitions (like LD_PRELOAD) are present in /etc/sysconfig/mysql (for compatibility) and/or /etc/sysconfig/mariadb without the need to change unit file or do extra "systemctl set-environment ..." calls,



 Comments   
Comment by Daniel Black [ 2019-04-10 ]

Historically sysv init scripts read /etc/sysconfig/X files to vary the init behaviour and that seems to have propagated to the assumption (for upgrade compatibility?) that systemd needs them too.

MariaDB's systemd documentation shows clearly how to use the drop-in directories of systemd to add/change/alter settings without replacing the service definition or using systemctl set-environment... in a much more flexible way than what /etc/sysconfig/X could provide. Even the MySQL systemd document shows using the drop-in directory to set the environment variables LD_PRELOAD and TZ.

If loader or glibc tunables environment variables are needed, they could be set using a dropin extension:

sudo tee /etc/systemd/system/mariadb.service.d/ld_preload.conf <<EOF
[Service]
 
Environment="LD_PRELOAD=/path/to/x.so"
EOF
sudo systemctl daemon-reload

So I'm not sure why 'EnvironmentFile=-/etc/sysconfig/mariadb' would be needed. Seems like bringing in a legacy mechanism, without a legacy requirement, when an existing mechanism exists.

The legacy (in systemd sense) mechanism was mysqld_safe (which systemd doesn't use, and mariadb-service-convert provide migrations), which had quite different schematics for variation of init based systems than /etc/sysconfig/X environment variable.

Generated at Thu Feb 08 08:50:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.