[MDEV-20863] debian logrotate errors Created: 2019-10-19  Updated: 2021-12-03  Resolved: 2021-12-03

Status: Closed
Project: MariaDB Server
Component/s: Platform Debian
Affects Version/s: 10.3.18
Fix Version/s: N/A

Type: Bug Priority: Trivial
Reporter: RobJE Assignee: Otto Kekäläinen
Resolution: Duplicate Votes: 1
Labels: None
Environment:

user@saihs:~$ uname -a
Linux saihs.renf.us 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 GNU/Linux
user@saihs:~$ cat /etc/debian_version
10.1
user@saihs:~$ dpkg -l mariadb-server-10.3
Desired=Unknown/Install/Remove/Purge/Hold

Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
/ Name Version Architecture Description
+++======================================================================================
ii mariadb-server-10.3 1:10.3.18+maria~buster amd64 MariaDB database server binaries
renf@saihs:~$

Issue Links:
PartOf
is part of MDEV-22659 Create one single unified and optimal... Closed

 Description   

When logrotate is done, an error email is generated

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

This is due to the command

my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"

generating multiple (in my case 3) output lines. Two of these are because pid-file is defines in /etc/mysql/my.cnf and in /etc/mysql/mariadb.conf.d/50-server.cnf.

The fix implemented in Debian proper is to limit this output to 1 line using

grep -m 1

.

Please update logrotate script line to

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



 Comments   
Comment by RobJE [ 2019-10-19 ]

maybe a regression of MDEV-11884 ?

Comment by Pablo Catalina [ 2019-10-24 ]

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

Comment by RobJE [ 2020-02-24 ]

parameter -m1 limits grep output to one line.

because of this the command

tail -n1

does not do much

This would be a better solution:

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

Comment by Otto Kekäläinen [ 2020-04-14 ]

See https://github.com/MariaDB/server/pull/934 and https://salsa.debian.org/mariadb-team/mariadb-10.4/-/commit/143569f09de024e7e3c2fc82074012e0cbbcd207 or simply start using existing `support-files/mysql-log-rotate.sh` in Debian packages as well.

Comment by Otto Kekäläinen [ 2021-04-04 ]

Superseded by https://github.com/MariaDB/server/pull/1556 and MDEV-22659.

Comment by Otto Kekäläinen [ 2021-12-03 ]

This will be fixed via MDEV-22659

Generated at Thu Feb 08 09:02:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.