Summary: | Upgrading from dev-db/mysql-4.0.20 to dev-db/mysql-4.0.20-r1 broke mod_php | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Whit Blauvelt <whit> |
Component: | New packages | Assignee: | Gentoo Linux MySQL bugs team <mysql-bugs> |
Status: | RESOLVED NEEDINFO | ||
Severity: | normal | ||
Priority: | High | ||
Version: | unspecified | ||
Hardware: | x86 | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Whit Blauvelt
2004-09-27 14:44:05 UTC
What I was missing was the ebuild changed the perms on /var/lib/mysql so mysql.sock wasn't available to php! This needs to be fixed in the ebuild, imho. Apache/php is not going to be running as root or as mysql.mysql, so this is just broken for anyone who keeps mysql.sock there (a standard location, although not the Gentoo default - but Gentoo doesn't keep anything else there, so this is all it seems it would apply to). The problem was introduced by the lines if [ -z "${DATADIR}" ]; then DATADIR="/var/lib/mysql/" fi chown -R mysql:mysql ${DATADIR} chmod 0750 ${DATADIR} in the ebuild. Since this was an upgrade rather than a fresh install, could the ebuild have instructed emerge to leave well enough alone? In almost all existing installations a data dir will already exist, and can be found by examining my.cnf (if emerge has access to that?). In any case /var/lib/mysql is not my data dir, but it is where (for historical reasons - it's standard on non-Gentoo mysql setups) I keep mysql.sock. Shouldn't this sort of ownership/permissions change be left up to the user anyway? In a fresh install, it's fine to use defaults, but when directories exist, should the ebuild be making this sort of assumption about their current use? The real bug looks like it's in: DATADIR=`my_print_defaults mysqld | sed -ne '/datadir/s|^--datadir=||p' | tail -n1` which has replace the older line from .20: DATADIR=`/usr/sbin/mysqld --help |grep '^datadir' | awk '{print $2}' So that first one for some reason failed on my system, thus cascading to the perms being reset wrong (for this system). Maybe revert to the version that works?? Yikes, the problem was still further upstream, I think. That command does show the right data dir now. But the ebuild had _replaced_ my my.cnf without asking. I'd replaced it back - I checked that before restarting and caught it. But my guess is the line got the wrong data dir because that came after emerge had substituted the default my.cnf over the working one. Can't recall seeing that happen before, and haven't changed any settings on what to protect from such overwriting. In any case, it looks like it must have happened before the ebuild got to that line. Correction on that last: The substitution of my.cnf must have been my own mistake post-installation. But, I have another system, same my.cnf, same upgrade, and the ebuild also changed the ownership and perms on /var/lib/mysql - so for some reason that my_print_defaults line in the new ebuild file is not succeeding in the context it's run - while the older grep method had worked fine when upgrading on both these systems to .20. This is still broken as of mysql-4.0.22. Why has there been absolutely no attention to this? If you look above I identified where the ebuild script is buggy. Please fix it. If you looked closer at the 4.0.22 ebuild, you would see that the only place your referenced lines: if [ -z "${DATADIR}" ]; then DATADIR="/var/lib/mysql/" fi chown -R mysql:mysql ${DATADIR} chmod 0750 ${DATADIR} exist is inside the pkg_config function - which should only ever be run manually by the user on new installs. Regardless, in 4.0.23, i've put in some einfo statements that print out what directory they are about to operate on. I just did the upgrade to mysql-4.0.22 and it changed the perms on /var/lib/mysql so that mysql.sock could not be written there. I did not run anything manually, and it was not a new install. It did this on two different systems. And /var/lib/mysql is not the datadir in my installations. I don't believe /var/lib/mysql is the default place for mysql.sock to go in Gentoo, however it's a fairly standard place to put it. So to sum up, "emerge -u mysql" will take a system in which my.cnf has the datadir somewhere else than /var/lib/mysql, and is using /var/lib/mysql to store mysql.sock (and nothing else), and will switch the perms on /var/lib/mysql so that it is no longer accessible on startup to put mysql.sock there - which stops mysql from running until the problem is tracked down and fixed. Maybe I didn't fully debug how that happens, but it wasn't a problem until 4.0.20-r1, it was still a problem in 4.0.22, and what you say you've done won't have fixed it unless by accident. Slight correction: When I said "stops mysql from running," what I should have said is "stops other programs (e.g. PHP) which connect through mysql.sock from accessing mysql (which can really screw up Web sites), since there is not a valid mysql.sock in /var/lib/mysql where they're looking for it. (What happens with the upgrade is that the perms get changed, and then the old mysql.sock - evident from its date - is still sitting there, but of course won't connect with the new instance of mysql. My initial report here missed the wrong date on mysql.sock.) Change the perms on /var/lib/mysql back, restart mysql, and it's fixed. But it shouldn't be up to the user to do that - it's an ebuild malfunction that produced it. Mysql does start in this situation, it just won't successfully create mysql.sock in /var/lib/mysql, because the perms have been inappropriately changed to no good end (although if that were the datadir in the installation, there would be a good end to it). I've just put 4.0.22-r1 in the tree, specially for you. Try it (it's only in ~x86 so that stable users don't get it, it's very similar to the old 4.0.22). If it does still cause the problem, debug it more throughly, by altering the ebuild to display the permissions of /var/lib/mysql around places you think it is being changed. no response from user. Didn't see your 12-23 message - probably went by it too fast while at relative's for the holiday. Is 4.0.22-r1 still the one to test, or has the modification been inherited by others since? Thanks. yes, 4.0.22-r1 is still the version to test, or the new 4.0.24-r1 which will be in CVS soon. no response from user. |