[MDEV-15543] systemd-tmpfiles.d should not be used to create the default datadir Created: 2018-03-12  Updated: 2023-11-28  Resolved: 2023-11-28

Status: Closed
Project: MariaDB Server
Component/s: Packaging
Affects Version/s: 10.1, 10.2, 10.3
Fix Version/s: 11.4.1

Type: Bug Priority: Major
Reporter: Fabien Hochstrasser Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: systemd

Issue Links:
Relates
relates to MDEV-17028 Fix glitches with systemd sysusers a... Closed
relates to MDEV-15052 Allow sysusers and tmpfiles install f... Closed
relates to MDEV-22893 Use systemd sysusers and tmpfiles in ... Open

 Description   

The package MariaDB-server installs the file /usr/lib/tmpfiles.d/tmpfiles.conf with the following content:

d /var/lib/mysql 0755 mysql mysql -

The man page of systemd-tmpfiles.d says the following:

systemd-tmpfiles uses the configuration files from the above directories to describe the creation, cleaning and removal of volatile and temporary files and directories which usually reside in directories such as /run or /tmp.

/var/lib/mysql is not a temporary nor volatile directory. It should not be created using systemd-tmpfiles.d. It's also a problem if a different datadir is being used (/var/lib/mysql is created at system startup without content).



 Comments   
Comment by Elena Stepanova [ 2018-05-30 ]

it was introduced in 10.1 by this commit:

commit 7bbc6c14d1e8fcf1f4737e0a5fcf6237fe18bd23
Author: Christian Hesse
Date:   Fri May 19 15:45:07 2017 +0200
 
    Generate and install sysusers and tmpfiles configuration
    
    Using systemd we can automate creating users and directories. So
    generate and install the configuration files.
    
    Signed-off-by: Vicențiu Ciorbaru
    
    Small change in cmake/install_layout.cmake compared to original contributor
    patch to also install SYSTEMD_SYSUSERS and SYSTEMD_TMPFILES directories. The
    variables were being set, but the loop which defines the final install files
    was not updated.

Thus assigning to cvicentiu to clarify.

Comment by Christian Hesse [ 2019-02-13 ]

I had to think twice what happens here...
You mix MYSQL_UNIX_DIR and MYSQL_DATADIR, please review your build configuration!
The former should point to /run/mysqld/ and holds the socket file mysqld.sock, the latter ist for the actual database data.

So this issue is invalid as /run/mysqld/ is in fact a volatile directory.

In MDEV-17028 I want to create MYSQL_DATADIR form systemd-tmpfiles, but with different permissions. Please note this does not do any harm to the data. From man tmpfiles.d:

d
Create a directory. The mode and ownership will be adjusted if specified. Contents of this directory are subject to time based cleanup if the age argument is specified.

D
Similar to d, but in addition the contents of the directory will be removed when --remove is used.

Everything is fine as long as we do not use capital "D" (or give an age).

Comment by Christian Hesse [ 2019-02-13 ]

BTW, if you read about direcroties in man tmpfiles.d it ends with:

... as well as some other directories below /var).

So this is not generally wrong.

Comment by Fabien Hochstrasser [ 2019-02-14 ]

I'm not building it myself, I use the RPM hosted on the official MariaDB repositories.
As you say, the MYSQL_DATADIR is for the actual database data. But I changed the datadir path, meaning /var/lib/mysql is not used.
In a perfect world /var/lib/mysql should not be created if a different path is configured for datadir. That's all I wanted to report.

I agree it isn't a problem to have this empty directory, but it would be even cleaner to not have it.

If you think it isn't worth fixing, no problem. You know better than me

Comment by Daniel Black [ 2023-11-14 ]

updated

Comment by Vicențiu Ciorbaru [ 2023-11-28 ]

Ok to push, with typo changed.

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