Code review comment for lp:~ebergen/maria/mysqld_safe_fix

Revision history for this message
Eric Bergen (ebergen) wrote :

On Mon, Feb 25, 2013 at 5:40 AM, Michael Widenius <email address hidden> wrote:
> Hi!
>>>>>> "Eric" == Eric Bergen <email address hidden> writes:
> Eric> Eric Bergen has proposed merging lp:~ebergen/maria/mysqld_safe_fix into lp:maria.
> Eric> Requested reviews:
> Eric> Maria-captains (maria-captains)
> Eric> For more details, see:
> Eric>
> Eric> This contains two changes to
> Eric> The first adds an option --crash-script for a script to call when mysqld crashes. This can be useful for gathering extra information, notifying operators, or triggering a failover when using HA.
> This part is ok.
> Eric> The second removes a rm command that deleted the sock file. This could delete the sock file for another instance when MYSQL_UNIX_PORT environment variable is set.
> What you removed was:
> - rm -f $safe_mysql_unix_port "$pid_file" # Some extra safety
> You can't remove the delation of "$pid_file";
> Without that will not properly.

mysqld_safe does a proper pid file check earlier and fails with an
error message if the stale pid file can't be cleaned up. The server
also opens the pid file with O_TRUNC so it will also get cleaned up.

> There is one problem with not removing the socket port:
> - If you don't do that, mysqld will not restart from a crash as the
> old socket file will stop the server from starting.

The server does a blind unlink call on the socket file prior to
creating a new one so it won't fail on a stale socket file.

> Eric> This caused problems for me because I use a non-standard installation. Upgrading the MariaDB-Server rpm would delete the sock file from my relocated mysqld leaving it orphaned.
> If you specify "socket" in your my.cnf, this should never go wrong.
> If you don't specify "socket" and you have another MySQL server
> running, your new server should not start as the socket file would be
> conflicting.
> Can you please describe in litte more detail how your installation
> looked like where you got conflicting socket names?

This happens when relocating a mysql instance from the default paths
provided in rpms. It is fairly common to relocate mysql for developers
to use a server with their own instances.

The problem showed up for me when a user was setting
MYSQL_UNIX_PORT=/home/user/path/to/relocated/mysql.sock and then
upgraded the MariaDB-Server package. The mysqld_safe executed during
the rpm installation deleted the relocated mysql_unix_port while
running the installation.

The real fix from my end is to manage MYSQL_UNIX_PORT better or to get
rid of it in favor of ~/.my.cnf. I found it odd that there was a line
with the comment "Some extra safety" implying that it didn't fix any
known issue. It was also doing cleanup that was harmful in my case and
not necessary.

> I will wait with applying your crash-script option until we find a
> solution for the above.
> Regards,
> Monty
> --
> You are the owner of lp:~ebergen/maria/mysqld_safe_fix.

Eric Bergen
<email address hidden>

« Back to merge proposal