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

Logrotate fails if mysqld is not running (logrotate_script: 3: [: /var/run/mysqld/mysqld.pid: unexpected operator)

Details

    Description

      From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830976

      > Followup-For: Bug #830976
      >
      >
      > I got  errors from cron:
      >  /etc/cron.daily/logrotate:
      >  logrotate_script: 3: [: /var/run/mysqld/mysqld.pid: unexpected operator
      >
      > The reason I found: The postrotate script of /etc/logrotate.d/mysql-server
      > contains
      >   my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"
      > and this generates on my machine two identical lines of output:
      > /var/run/mysqld/mysqld.pid
      > /var/run/mysqld/mysqld.pid
      >
      > So I added  " | uniq"  after the grep. Perhaps " | head -n1"
      > would be even better.
       
       
      I seems this was introduced in commit
      https://anonscm.debian.org/cgit/pkg-mysql/mariadb-10.0.git/commit/debian/mariadb-server-10.0.mysql-server.logrotate?id=2948deb77b61f805e41b7032c71226a69d29a317
      when importing upstream 10.0.25.
       
      The original upstream commit that changed this was
      https://github.com/MariaDB/server/commit/8942824a5304e23f765b88d07498786d80092843
       
      I suggest you work directly with upstream to get this syntax fine
      tuned and fixed globally.
      

      Attachments

        Issue Links

          Activity

            This has been fixed in Debian 10.1.22-1 version of the package.

            oerdnj Ondřej Surý (Inactive) added a comment - This has been fixed in Debian 10.1.22-1 version of the package.
            Ovidiu Ovidiu added a comment - - edited

            Sorry for commenting on an older thread but I have a Debian server where I replaced MYSQL server with MariaDB and since then I continuously get error messages from logrotate.

            I am running the following up-to-date versions

            • Debian 9.4
            • 10.2.14-MariaDB
            • logrotate 3.11.0

            I'm unsure how to fix this error. Can someone help me out here?

            /etc/cron.daily/logrotate:
            logrotate_script: 3: [: /var/run/mysqld/mysqld.pid: unexpected operator
            

            Ovidiu Ovidiu added a comment - - edited Sorry for commenting on an older thread but I have a Debian server where I replaced MYSQL server with MariaDB and since then I continuously get error messages from logrotate. I am running the following up-to-date versions Debian 9.4 10.2.14-MariaDB logrotate 3.11.0 I'm unsure how to fix this error. Can someone help me out here? /etc/cron.daily/logrotate: logrotate_script: 3: [: /var/run/mysqld/mysqld.pid: unexpected operator
            kiba kiba added a comment -

            Same here, I'm on:

            • Debian 9.4
            • 10.2.15-MariaDB
            • logrotate 3.11.0

            workaround is just add -m1 argument to grep:

            if [ -f `my_print_defaults --mysqld | grep -oPm1 "pid-file=\K[^$]+"` ]; then
            

            kiba kiba added a comment - Same here, I'm on: Debian 9.4 10.2.15-MariaDB logrotate 3.11.0 workaround is just add -m1 argument to grep: if [ -f `my_print_defaults --mysqld | grep -oPm1 "pid-file=\K[^$]+" ` ]; then

            The fix implemented in Debian is not a proper solution, as the process will use the latest definition of a variable. So the 1st instance in /etc/mysql/my.cnf will be overwritten with the second instance in /etc/mysql/mariadb.conf.d/50-server.cnf. Or, potentially in other custom definitions of the variable.

            It is better to use:

            if [ -f $(my_print_defaults --mysqld | grep -m1 -oP "pid-file=\K[^$]+") | tail -n1 ]; then
            

            xkill Pablo Catalina added a comment - The fix implemented in Debian is not a proper solution, as the process will use the latest definition of a variable. So the 1st instance in /etc/mysql/my.cnf will be overwritten with the second instance in /etc/mysql/mariadb.conf.d/50-server.cnf. Or, potentially in other custom definitions of the variable. It is better to use: if [ -f $(my_print_defaults --mysqld | grep -m1 -oP "pid-file=\K[^$]+" ) | tail -n1 ]; then
            xkill Pablo Catalina added a comment - Fix on pull request: https://github.com/MariaDB/server/pull/934

            People

              otto Otto Kekäläinen
              otto Otto Kekäläinen
              Votes:
              0 Vote for this issue
              Watchers:
              6 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.