Bug #27072 RPM installation/upgrade autostarts mysqld
Submitted: 13 Mar 2007 9:38 Modified: 14 Oct 2010 13:22
Reporter: Kristian Koehntopp Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:mysql-server-5.0.36 OS:Linux (any RPM)
Assigned to: Joerg Bruehe CPU Architecture:Any
Tags: autostart, autoyast, installation

[13 Mar 2007 9:38] Kristian Koehntopp
Description:
All our rpm packages for Linux autostart the mysqld upon installation. 

According jro@suse.de (Jochen Röder) this is wrong and makes it impossible to install our rpms as part of autoyast installations, because at the point in time when the installation is running the actual system state is undetermined.

The workaround currently is to run our rpm installation manually in a postinstall script.

How to repeat:
rpm -Uvh mysql*server*rpm

and watch the install script start mysqld. This must not happen.

Suggested fix:
Do not start the mysql server as part of the installation.
[13 Mar 2007 10:33] Valeriy Kravchuk
Thank you for a problem report. Verified, as this is well-known behaviour of all our RPMs.
[15 Mar 2007 19:03] Joerg Bruehe
I accept all arguments that autostart during installation may be wrong
(in fact, I feel the same).

However, this is established behaviour in a GA release,
and I dare not change that (change in functionality).

So unless there is strong agreement from Support with such a change during 5.0,
we should postpone it to the switch from 5.0 to 5.1.
[16 Mar 2007 12:11] Lenz Grimmer
I solicited some input from our users on this: http://lenz.homelinux.org/archives/114-To-start-or-not-start-the-MySQL-server-during-the-R...
[16 Mar 2007 19:37] Kristian Koehntopp
I agree with the evaluation of Jörg.
[22 Mar 2007 5:48] Oli Sennhauser
See also bug #25656
[22 Mar 2007 8:37] Sveta Smirnova
Bug #25656 was marked as duplicate of this one.
[27 Oct 2009 20:38] Simon Mudd
5.1 is now GA. (2 years after the original bug report)
And 5.4 is almost released. Are you planning on fixing this yet? Do we need to wait for MySQL 7.0 for this to be changed?

This same issue also applies to upgrades (which I know are basically an rpm removal followed by an install).

Other rpm packages arrange things so that if the package to be upgraded is not running then the new (upgraded) package won't be started. Together with the don't start on initial install this would make life much better.

The other option is to provide a mechanism which if present will make the package installer/upgrader deliberately not startup/build the empty database. A file like:

/etc/sysconfig/mysql (normally not present) with some custom variables:

MYSQLD_DO_NOT_START_ON_PACKAGE_INSTALL=1, or
MYSQLD_RESTART_ON_PACKAGE_UPGRADE_IF_RUNNING=1

These are all "hacks" but allow us to modify "standard behaviour" to fit in with site requirements.
[11 Jun 2010 17:31] Joerg Bruehe
Fixing the synopsis.

I have a proof-of-concept for a fix and will discuss it via mail,
both internally and on the public "internals" mailing list.
[11 Jun 2010 18:00] Joerg Bruehe
Quoting my own mail to the public list  internals@lists.mysql.com :

I have now finished and checked a fix that will make the installation
and upgrade of the MySQL server (via RPM packages) behave as follows:

- On first installation, the start/stop scripts will be installed in
  "/etc/init.d" and symlinked to the run level directories,
  which will cause the MySQL server to be started whenever the machine
  boots up.
  However, to do as demanded in the bug report, the MySQL server will
  not be started directly during installation, but at the next reboot
  (unless the sysadmin changed the symlink entries to the run level
  directories).

- On an upgrade, the "pre" section of the RPM spec file will check
  whether the MySQL server is running or not.
  It will, using an entry in a file, transfer this knowledge to the
  "post" section of the spec file, and then stop the server.
  Then, the old binaries will be replaced by the new ones, as usual.
  The "post" section will check that file entry:
  If the server process was running before the upgrade, the new binaries
  will be autostarted during the upgrade step.
  If the server process had been stopped before the upgrade, no
  autostart will be done, but the start/stop script will be entered into
  the system - so as with installation, the server will be started on
  the next reboot.
  In short words: After an upgrade (via RPM), the MySQL server will be
  running if and only if it was running before the upgrade.
[15 Jun 2010 20:28] 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/111195

3394 Joerg Bruehe	2010-06-15
      Fix bug#27072:  RPM autostarts the server
      
      This is the fix for 5.1, where only the behaviour on upgrade is changed:
      If the server was stopped when the upgrade begins, we assume the
      administrator is taking manual action, so we do not start the (new)
      server at the end of the upgrade.
      We still install the start/stop script, so it will be started on reboot.
     @ support-files/mysql.spec.sh
        In the "pre" section of the spec file, check the server status, and write
        the result to a file.
        In the "post" section, evaluate the status file, and start the server if
        it was running during status analysis.
        In 5.1, we start the server if there is no status file (which will happen
        on first installation, when there is no data directory yet).
[15 Jun 2010 20:47] 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/111199

3096 Joerg Bruehe	2010-06-15 [merge]
      Fix bug#27072:  RPM autostarts the server
      
      This is the fix for 5.5, where the behaviour on both installation
      and upgrade is changed:
      On installation, we do not start the server, to allow automated
      installs (which happen in some indeterminate machine status).
      If the server was stopped when the upgrade begins, we assume the
      administrator is taking manual action, so we do not start the (new)
      server at the end of the upgrade.
      We still install the start/stop script, so it will be started on reboot.
     @ support-files/mysql.spec.sh
        In the "pre" section of the spec file, check the server status, and write
        the result to a file.
        In the "post" section, evaluate the status file, and start the server if
        it was running during status analysis.
        In 5.5, we do *not* start the server if there is no status file (which will happen on first installation, when there is no data directory yet).
[15 Jun 2010 20:50] 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/111200

3245 Joerg Bruehe	2010-06-15 [merge]
      Automerge the fix for bug#27072 from "trunk" to "next-mr", no code differences.
[17 Jun 2010 9:12] Daniel Fischer
Looks good.
[17 Jun 2010 11: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/111401

3249 Joerg Bruehe	2010-06-17 [merge]
      Automerge the fix for bug#27072 (RPM autostarts the server) into
      "next-mr-nugfixing".
[17 Jun 2010 11:08] 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/111405

3434 Joerg Bruehe	2010-06-17 [merge]
      Automerge the fix for bug#27072 into 5.1-bugteam
[17 Jun 2010 11:12] 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/111408

3098 Joerg Bruehe	2010-06-17 [merge]
      Automerge the fix for bug#27072 into trunk-bugfixing.
[17 Jun 2010 11:55] Joerg Bruehe
Docs team:
I expect this fix to become part of 5.5.5 and 5.1.49.

When you document this in the manual, please check my comments from the commit entries above, and note that the functional change in RPM "install" applies to 5.5 only, whereas the one in RPM "update" also applies to 5.1.
[22 Jun 2010 13:09] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100622130139-u05awgya93zvbsop) (version source revid:alik@sun.com-20100622130139-u05awgya93zvbsop) (merge vers: 5.5.5-m3) (pib:16)
[22 Jun 2010 13:11] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100622130623-r7yhm89fz9n5t9nb) (version source revid:alik@sun.com-20100622130528-187gd949sa9b6pa6) (pib:16)
[22 Jun 2010 16:45] Joerg Bruehe
Automatic status change was missing ...
[29 Jun 2010 8:19] MC Brown
A note has been added to the 5.1 changelog: 

        The behavior of the RPM upgrade installation has changed. During                              
        an upgrade installation using the RPM packages, if the server is                              
        running when the installation occurs, the server is stopped, the                              
        upgrade occurs, and server is restarted. If the server is not                                 
        already running when the RPM upgrade occurs, the server is not                                
        started at the end of the installation. The boot scripts for                                  
        MySQL are installed in the appripriate directories in                                         
        <filename>/etc</filename>.  

A note has been added to the 5.5.5 changelog: 

        The behavior of the RPM installation for both new installations                               
        and upgrade installations has changed.                                                        

        During a new installation, the server boot scripts are                                        
        installed, but the MySQL server is not started at the end of the                              
        installation, since the status of the server during an                                        
        unattended installation is not known.                                                         

        During an upgrade installation using the RPM packages, if the                                 
        server is running when the installation occurs, the server is                                 
        stopped, the upgrade occurs, and server is restarted. If the                                  
        server is not already running when the RPM upgrade occurs, the                                
        server is not started at the end of the installation.                                         
 
The corresponding areas of the RPM installation documentation has also been updated.
[19 Jul 2010 14:37] Bugs System
Pushed into 5.1.49 (revid:build@mysql.com-20100719143034-omcma40sblwmay3x) (version source revid:joerg@mysql.com-20100617110733-6mxg8mp1ugpf96fm) (merge vers: 5.1.48) (pib:16)
[20 Jul 2010 13:20] MC Brown
Already documented; no further changes required.
[4 Aug 2010 8:04] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:alik@sun.com-20100622130528-187gd949sa9b6pa6) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 8:20] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:alik@sun.com-20100622130528-187gd949sa9b6pa6) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 23:05] Paul DuBois
Bug does not appear in any released 5.6.x version.
[14 Oct 2010 8:28] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (merge vers: 5.5.5-m3) (pib:21)
[14 Oct 2010 8:43] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (merge vers: 5.5.5-m3) (pib:21)
[14 Oct 2010 8:58] Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (merge vers: 5.5.5-m3) (pib:21)
[14 Oct 2010 13:12] Jon Stephens
Already documented in the 5.1.49 changelog. No additional changelog entries required. Closed.