[Commits] 178cddd: MDEV-9082 - Debian: mysql_install_db is called on upgrade

Sergey Vojtovich svoj at mariadb.org
Thu Nov 5 12:00:15 EET 2015


revision-id: 178cddd664cb4ce2c6ccbe76c33e4fd2c1fc1b3d (mariadb-10.1.8-25-g178cddd)
parent(s): 2ef562d2c74297b0b92c4322697dad98767cc873
committer: Sergey Vojtovich
timestamp: 2015-11-05 13:57:24 +0400
message:

MDEV-9082 - Debian: mysql_install_db is called on upgrade

A comment in debian/mariadb-server-10.1.postinst says: "can safely run on
upgrades with existing databases". While this is true there're a few reasons not
to do that:
- it increases installation time (it has to run rather heavy mysqld multiple times)
- as well as it increases mysqld downtime
- it may fail if database has some plugin specific configs (see MDEV-8437)
- there should be no need to run this script on upgrade: they should be handled
  by mysql_upgrade to
- RPM postin doesn't call it if database directory exists

Also postinst is not supposed to create database directories: let
mysql_install_db do that intead.

---
 debian/mariadb-server-10.1.postinst | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/debian/mariadb-server-10.1.postinst b/debian/mariadb-server-10.1.postinst
index 40492a2..0f35802 100644
--- a/debian/mariadb-server-10.1.postinst
+++ b/debian/mariadb-server-10.1.postinst
@@ -104,8 +104,10 @@ EOF
     
     # Ensure the existence and right permissions for the database and
     # log files.
-    if [ ! -d "$mysql_statedir"       -a ! -L "$mysql_statedir"       ]; then mkdir "$mysql_statedir"; fi
-    if [ ! -d "$mysql_statedir/mysql" -a ! -L "$mysql_statedir/mysql" ]; then mkdir "$mysql_statedir/mysql"; fi
+    if [ ! -d "$mysql_statedir/mysql" -a ! -L "$mysql_statedir/mysql" ]; then
+      # Debian: beware of the bashisms...
+      /bin/bash /usr/bin/mysql_install_db --rpm --user=mysql --disable-log-bin 2>&1 | $ERR_LOGGER
+    fi
     if [ ! -d "$mysql_newlogdir"      -a ! -L "$mysql_newlogdir"      ]; then mkdir "$mysql_newlogdir"; fi
     # When creating an ext3 jounal on an already mounted filesystem like e.g.
     # /var/lib/mysql, you get a .journal file that is not modifyable by chown.
@@ -130,16 +132,6 @@ EOF
 
     # To avoid downgrades.
     touch $mysql_statedir/debian-10.1.flag
-
-    # initiate databases. Output is not allowed by debconf :-(
-    # This will fail if we are upgrading an existing database; in this case
-    # mysql_upgrade, called from the /etc/init.d/mysql start script, will
-    # handle things.
-    # Debian: beware of the bashisms... 
-    # Debian: can safely run on upgrades with existing databases 
-    set +e
-    /bin/bash /usr/bin/mysql_install_db --rpm --user=mysql --disable-log-bin 2>&1 | $ERR_LOGGER
-    set -e
     
     ## On every reconfiguration the maintenance user is recreated.
     #


More information about the commits mailing list