Hi Lennart, I adjusted your patch a bit, it seem to work well for me. Could you please verify if you're fine with the attached version and it works for you too?
On Mon, Mar 07, 2016 at 04:35:43PM +0100, Lennart Weller wrote: > On Mon, Mar 07, 2016 at 06:37:49PM +0400, Sergey Vojtovich wrote: > > Existence of pid-file is a sure sign that there's mysqld running, the only > > exception is mysqld crash. What do you think about skipping this check? > > > > I'd also suggest to turn things around and check for pid-file first and then > > just run "MYADMIN flush-logs" allowing it to return error in case of > > failure. > > Yep. Switched the order for this one. But mysqladmin does not return 1 > when it fails to connect. Did some additional testing. For now I put it > back to the way it was in the original logrotate and just check if > stdout/stderr of the command is null. > This probably merits a second bug report. You mean "$($MYADMIN flush-logs)" doesn't return 1? I just tested it on my side and got exit status 1. Thanks, Sergey
diff --git a/debian/mariadb-server-10.0.mysql-server.logrotate b/debian/mariadb-server-10.0.mysql-server.logrotate index 789ad35..a19e9ec 100644 --- a/debian/mariadb-server-10.0.mysql-server.logrotate +++ b/debian/mariadb-server-10.0.mysql-server.logrotate @@ -10,18 +10,11 @@ compress sharedscripts postrotate - test -x /usr/bin/mysqladmin || exit 0 + test -x /usr/bin/mysqladmin || exit 0 - # If this fails, check debian.conf! - MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" - if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then - # Really no mysqld or rather a missing debian-sys-maint user? - # If this occurs and is not a error please report a bug. - if ps cax | grep -q mysqld; then - exit 1 - fi - else - $MYADMIN flush-logs - fi + if [ -f `my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"` ]; then + # If this fails, check debian.conf! + mysqladmin --defaults-file=/etc/mysql/debian.cnf flush-logs + fi endscript }