Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-19436: Fix logrotate problem with twice configured pid-file option #934

Merged
merged 3 commits into from
Dec 3, 2021

Conversation

odenbach
Copy link
Contributor

Hi,

if the pid-file option is configured more than once (e.g. multiple times in different files), my_print_defaults prints it twice, resulting in the logrotate postrotate script failing because of a syntax error. Debian fixed this already (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830976#42).

Perhaps you could implement this small change in the other branches as well?

Thanks,

Christopher

Hi,

if the pid-file option is configured more than once (e.g. multiple times in different files), my_print_defaults prints it twice, resulting in the logrotate postrotate script failing because of a syntax error. Debian fixed this already (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830976#42).

Perhaps you could implement this small change in the other branches as well?

Thanks,

Christopher
@an3l
Copy link
Collaborator

an3l commented Nov 22, 2018

Hi @odenbach,

Thanks for your contribution.

Similar to other open source projects, the MariaDB Foundation needs to have shared ownership of all code that is included in the MariaDB distribution. The easiest way to achieve this is by submitting your code under the BSD-new license.

The other alternative is to sign the code contribution agreement which can be found here: https://mariadb.com/kb/en/mariadb/mca/

Please indicate in a comment below, or update your PR comment that you are contributing your new code of the whole pull request, including one or several files that are either new files or modified ones, under the BSD-new license or that you have filled out the contribution agreement and sent it.

Thanks,
Anel

@an3l an3l added this to the 10.4 milestone Nov 22, 2018
@odenbach
Copy link
Contributor Author

BSD-new is fine.

@an3l an3l added the license-bsd-new Contributed under BSD-new license label Nov 22, 2018
@an3l
Copy link
Collaborator

an3l commented Mar 12, 2019

@fauust can you please take a look?

@grooverdan
Copy link
Member

Actually the real problem is checking there is a pidfile. There may not be one existing with systemd and mariadb-10.1+ but mariadb may still be running. You be better just running mysqladmin and ignoring the socket not found error (exit status 1).

@odenbach
Copy link
Contributor Author

odenbach commented Apr 3, 2019

Hi,

I just switched over to using mysqladmin ping instead of looking for pid files. This really seems to make much more sense. I tried it with the server running and without, looked good.

Cheers,

Christopher

@grooverdan
Copy link
Member

Good alternative. I like it. +1 from me.

@vuvova vuvova self-assigned this Apr 7, 2019
@odenbach
Copy link
Contributor Author

Hi,

should I provide anything else? The checks above obviously failed for some totally other reason.

Thanks,

Christopher

@an3l an3l changed the title Fix logrotate problem with twice configured pid-file option MDEV-19436: Fix logrotate problem with twice configured pid-file option May 10, 2019
if [ -f `my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"` ]; then
# If this fails, check debian.conf!
# check if server is running
if mysqladmin ping > /dev/null 2>&1; then
mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd simply remove the whole check and just run

mysqladmin flush-engine-log flush-general-log flush-slow-log 2>&1 >/dev/null || :

if mysqladmin ping will fail to connect then mysqladmin flush can fail just the same, no need to run it twice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to fix it yourself or you'd prefer me to do this simple change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you just drop any error messages you will not get noticed if the flush-log command fails for any other reason (e.g. file system full). I would rather prefer my version: Making sure the server can listen to commands and then telling it what to do.

@obendev
Copy link

obendev commented Mar 9, 2020

Any news on this? I think it's a good solution.

@CLAassistant
Copy link

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@ottok ottok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ottok
Copy link
Contributor

ottok commented Apr 13, 2020

Note that there is also a support-files/mysql-log-rotate.sh which in CMake build is added to debian/tmp/etc/logrotate.d but not installed. I am considering using it in #1498 so we in future have just one single logrotate script across all distros.

@grooverdan
Copy link
Member

if you do, @localstatedir@ (currently defined to datadir in support-files/CMakeLists.txt) in support-files/mysql-log-rotate.sh should be changed to something like @logdir@ and cmake/install_layout.cmake to include INSTALL_LOGDIR_{DEB,RPM,STANDALONE,SRV4}.

support-files/CMakeLists.txt will need SET(logdir ${INSTALL_LOGDIRABS} instead of previous localstatedir.

@ottok
Copy link
Contributor

ottok commented May 21, 2020

While this PR is correct, the whole logrotate thing needed an overhaul, so I filed https://jira.mariadb.org/browse/MDEV-22659 and made #1556 which if merged would obsolete this.

@grooverdan grooverdan merged commit 658a1e1 into MariaDB:10.4 Dec 3, 2021
@grooverdan
Copy link
Member

Thanks @obendev - finally merged for older versions.

@odenbach odenbach deleted the logrotate-fix branch December 3, 2021 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
license-bsd-new Contributed under BSD-new license
Development

Successfully merging this pull request may close these issues.

8 participants