Package upgrade on Ubuntu runs mysql_install_db even though data directory already exists

Bug #1457614 reported by Pim van der Wal
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.5
Fix Released
High
Tomislav Plavcic
5.6
Fix Released
High
Tomislav Plavcic
5.7
Invalid
Undecided
Unassigned

Bug Description

We recently ran into an error while upgrading from Percona Server 5.5.24 to 5.5.41 on Ubuntu Precise. When we upgraded the packages it ran the mysql_install_db script as part of the postinst configure. The mysql_install_db script writes system table ddl to the binary logs which then gets replicated to the slaves. I filed a bug with Oracle because mysql_install_db should not be writing to the binary log (https://bugs.mysql.com/bug.php?id=77122) but that is only part of the problem. The postinst should not run mysql_install_db when there is a working MySQL installation. If anything, it should run mysql_upgrade --skip-binlog-write in that case.

The following code in postinst causes the the issue:

    # initiate databases. Output is not allowed by debconf :-(
    # Debian: beware of the bashisms...
    # Debian: can safely run on upgrades with existing databases
    set +e
    bash /usr/bin/mysql_install_db --user=mysql --rpm 2>&1 |
        $ERR_LOGGER
    if [ "$?" != "0" ]; then
      echo "ATTENTION: An error has occured. More info is in the syslog!"
    fi
    set -e

The direct error we encountered is that there was a replication conflict as the slave got upgraded after the master and mysql_upgrade ran simultaneously with the replicated statements. The bigger problem is that mysql_install_db drops and creates the performance_schema database which then gets replicated to all slaves.

Tags: pkg i60266 i64628
Revision history for this message
Kenny Gryp (gryp) wrote :

Yeah, and in postinst, the 'configure' part is getting executed during a package upgrade as well.

And it mentions in the comments
"# Debian: can safely run on upgrades with existing databases"

I don't think it's safe to run mysql_install_db on upgrades. This should be changed from the postinst and only be executed during a regular install.

tags: added: pkg
Revision history for this message
Valerii Kravchuk (valerii-kravchuk) wrote :

Confirmed by code review (on Ubuntu 14.10).

Revision history for this message
Sveta Smirnova (svetasmirnova) wrote :

Affects Debian packages as well

tags: added: i60266
Jervin R (revin)
tags: added: i64628
Revision history for this message
Tomislav Plavcic (tplavcic) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

5.7?

Revision history for this message
Tomislav Plavcic (tplavcic) wrote :

5.7 doesn't run initialization if the data directory exists, so it's not affected.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

OK, please update the bug status accordingly. Does it need a null merge to 5.7?

Revision history for this message
Tomislav Plavcic (tplavcic) wrote :

Bug status updated, null merge done before.

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-3285

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.