Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15543

systemd-tmpfiles.d should not be used to create the default datadir

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.1(EOL), 10.2(EOL), 10.3(EOL)
    • 11.4.1
    • Packaging

    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).

      Attachments

        Issue Links

          Activity

            elenst Elena Stepanova added a comment - - edited

            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.

            elenst Elena Stepanova added a comment - - edited 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.

            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).

            eworm Christian Hesse added a comment - 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).

            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.

            eworm Christian Hesse added a comment - 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.

            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

            Fabien Hochstrasser Fabien Hochstrasser added a comment - 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
            danblack Daniel Black added a comment -

            updated

            danblack Daniel Black added a comment - updated

            Ok to push, with typo changed.

            cvicentiu Vicențiu Ciorbaru added a comment - Ok to push, with typo changed.

            People

              danblack Daniel Black
              Fabien Hochstrasser Fabien Hochstrasser
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.