Bug #28555 Upgrading MySQL Fails to shut down old server and kills socket file
Submitted: 21 May 2007 9:38 Modified: 20 Mar 2008 18:42
Reporter: Peter Zaitsev (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.0.41 OS:Linux
Assigned to: Timothy Smith CPU Architecture:Any
Tags: qc

[21 May 2007 9:38] Peter Zaitsev
Description:
Upgrading "RedHat" 5.0 MySQL binaries to MySQL 5.0.41 community version results in following error message:

[root@DB02 tmp]# rpm -Uvh MySQL*
warning: MySQL-client-community-5.0.41-0.rhel4.x86_64.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing...                ########################################### [100%]
   1:MySQL-shared-compat    ########################################### [ 20%]
   2:MySQL-server-community ########################################### [ 40%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h  password 'new-password'
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
Warning! var/lib/mysql refers to a symbolic link, not following last component.
Starting MySQLCouldn't find MySQL manager or server[FAILED]
   3:MySQL-client-community ########################################### [ 60%]
   4:MySQL-community-debugin########################################### [ 80%]
   5:MySQL-devel-community  ########################################### [100%]
warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave
[root@DB02 tmp]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@DB02 tmp]# w
 04:13:56 up 28 days, 16:25,  4 users,  load average: 2.14, 2.16, 1.42
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
vadim    pts/2    web01            Sun10   17:28m  0.00s  0.00s screen -DR
vadim    pts/3    -                Sun10   17:28m  0.14s  0.14s /usr/bin/mc -P /tmp/mc-vadim/mc.pwd.18709 -abd
vadim    pts/5    -                Sun10    4days  0.58s  0.52s SCREEN -DR
pz       pts/7    web01            03:33    0.00s  0.09s  0.00s sshd: pz [priv]
[root@DB02 tmp]# ps aux | grep mysql
root      3980  0.0  0.0 53828 1320 ?        S    Apr22   0:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid --log-error=/var/log/mysqld.log
27        4013 85.8 83.3 13862380 13683864 ? Sl   Apr22 35452:03 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock

As you can see MySQL is not shut down, also after this process Socket file is removed:

[root@DB02 tmp]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Now it is worse 

/var/lib/mysql  was symlink in my case and that simlink is simply removed on MySQL upgrade attempt.  How smart !

If new MySQL version does not support such configuration any more It probably should refuse to upgrade.

Somebody could get a stroke finding /var/lib/mysql destroyed by install script :)

How to repeat:
See Above
[21 May 2007 13:51] Daniel Fischer
Verified: Upgrade from RHEl4 MySQL 4.1.20 to MySQL MySQL 5.0.41 fails, the server fails to start afterward, and the symlink is removed.
[29 May 2007 13:54] Mads Martin Joergensen
We cannot automatically support upgrading from one major version to another. I would very much prefer a %pre scriptlet testing the mysql version and in case it's so old, bail out with a comment that it's a major version upgrade.
[10 Jan 2008 20:49] Omer Barnir
Workaround: Remove or move the old binaries to a different location, stop the running MySQL server
[15 Feb 2008 9:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/42333

ChangeSet@1.2578, 2008-02-15 02:30:12-07:00, tsmith@ramayana.hindu.god +1 -0
  Bug #28555  Upgrading MySQL Fails to shut down old server and kills socket file
  
  Check for an existing MySQL server package from a different vendor or
  major MySQL version.  In such a case, refuse to install the server and
  recommend how to safely remove the old packages before installing the
  new ones.
[15 Feb 2008 10:56] Timothy Smith
[build@centos4-x86 ~]$ rpm -q --whatprovides mysql-server
no package provides mysql-server
[build@centos4-x86 ~]$ echo $?
1
[build@centos4-x86 ~]$ sudo rpm -Uvh centos-rpms/mysql-*.rpm
warning: centos-rpms/mysql-4.1.20-2.RHEL4.1.0.1.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821
Preparing...                ########################################### [100%]
   1:mysql                  ########################################### [ 33%]
   2:mysql-devel            ########################################### [ 67%]
   3:mysql-server           ########################################### [100%]
[build@centos4-x86 ~]$ rpm -q --whatprovides mysql-server
mysql-server-4.1.20-2.RHEL4.1.0.1
[build@centos4-x86 ~]$ sudo rpm -Uvh MySQL-*.i386.rpm
warning: MySQL-shared-compat-enterprise-gpl-5.0.54a-0.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing...                ########################################### [100%]
   1:MySQL-shared-compat-ent########################################### [ 17%]

******************************************************************
A MySQL server package (mysql-server-4.1.20-2.RHEL4.1.0.1) is installed.

The current MySQL server package is provided by a different
vendor (CentOS) than MySQL AB.

Upgrading directly from MySQL 4.1 to MySQL 5.0 may not
be safe in all cases.

A manual upgrade is required.  A recommended procedure is:

- Ensure that you have a complete, working backup of your data and my.cnf
  files
- Shut down the MySQL server cleanly
- Remove the existing MySQL packages.  Usually this command will
  list the packages you should remove:
  rpm -qa | grep -i '^mysql-'

  You may choose to use 'rpm --nodeps -ev <package-name>' to remove
  the package which contains the mysqlclient shared library.  The
  library will be reinstalled by the MySQL-shared-compat package.
- Install the new MySQL packages supplied by MySQL AB
- Ensure that the MySQL server is started
- Run the 'mysql_upgrade' program

This is a brief description of the upgrade process.  Important details
can be found in the MySQL manual, in the Upgrading section.
******************************************************************
error: %pre(MySQL-server-enterprise-5.0.50-0.rhel4.i386) scriptlet failed, exit status 1
error:   install: %pre scriptlet failed (2), skipping MySQL-server-enterprise-5.0.50-0.rhel4
   2:MySQL-client-enterprise########################################### [ 33%]
   3:MySQL-devel-enterprise ########################################### [ 50%]
   4:MySQL-enterprise-debugi########################################### [ 67%]
   5:MySQL-test-enterprise  ########################################### [ 83%]
[build@centos4-x86 ~]$ echo $?
6
[15 Feb 2008 10:59] Joerg Bruehe
I sent a review by mail.

The general approach seems fine to me, but I propose some changes in details.
[15 Feb 2008 17:49] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/42394

ChangeSet@1.2578, 2008-02-15 10:48:41-07:00, tsmith@ramayana.hindu.god +1 -0
  Bug #28555  Upgrading MySQL Fails to shut down old server and kills socket file
  
  Check for an existing MySQL server package from a different vendor or
  major MySQL version.  In such a case, refuse to install the server and
  recommend how to safely remove the old packages before installing the
  new ones.
[15 Feb 2008 23:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/42410

ChangeSet@1.2578, 2008-02-15 16:18:14-07:00, tsmith@ramayana.hindu.god +1 -0
  Bug #28555  Upgrading MySQL Fails to shut down old server and kills socket file
  
  Check for an existing MySQL server package from a different vendor or
  major MySQL version.  In such a case, refuse to install the server and
  recommend how to safely remove the old packages before installing the
  new ones.
[18 Feb 2008 19:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/42514

ChangeSet@1.2578, 2008-02-18 12:03:39-07:00, tsmith@ramayana.hindu.god +1 -0
  Bug #28555  Upgrading MySQL Fails to shut down old server and kills socket file
  
  Check for an existing MySQL server package from a different vendor or
  major MySQL version.  In such a case, refuse to install the server and
  recommend how to safely remove the old packages before installing the
  new ones.
[18 Feb 2008 21:34] Timothy Smith
Patch queued to 5.0-, 5.1-, and 6.0-build
[18 Feb 2008 21:35] Timothy Smith
Also updated internals/build/NetworkRPMS/mysql-5.{0,1}.spec.in.
[25 Feb 2008 15:59] Bugs System
Pushed into 5.1.24-rc
[25 Feb 2008 16:04] Bugs System
Pushed into 5.0.58
[25 Feb 2008 16:06] Bugs System
Pushed into 6.0.5-alpha
[20 Mar 2008 18:42] Paul DuBois
Noted in 5.0.58, 5.1.24, 6.0.5 changelogs.

For upgrading to a new major version using RPM packages (such as 4.1
to 5.0), if the installation procedure found an existing MySQL server
running, it could fail to shut down the old server, but also 
erroneously removed the server's socket file. Now the procedure
checks for an existing server package from a different vendor or
major MySQL version. In such case, it refuses to install the server
and recommends how to safely remove the old packages before 
installing the new ones.
[30 Mar 2008 9:08] Jon Stephens
Fixed also noted in the 5.1.23-ndb-6.3.11 changelog.