Dotdeb repository problems with MariaDB 5.5 (solution)

Dotdeb is a repository currently targeting Debian and Ubuntu, providing a nice set of packages for LAMP servers.

Recently, MySQL 5.6 was added to the dotdeb repository. On the surface, this is a very harmless addition. MariaDB is a replacement for MySQL and it should be possible for applications designed for MySQL to easily switch to MariaDB. Therefore MariaDB also includes the libraries that applications using MySQL depend upon, such as libmysqlclient18 and mysql-common. The dpkg package manager looks at the MySQL 5.6 packages in dotdeb and assumes that 5.6 is a higher version than 5.5, which results in it removing or replacing libraries during normal apt-get installation and upgrade procedures.

The problems appear in the following scenarios:

  1. apt-get install mariadb-server-5.5 (fresh or over a previous version)
  2. apt-get upgrade (if MariaDB 5.5 is installed)
  3. apt-get dist-upgrade (if MariaDB 5.5 is installed)

Scenario 3, dist-upgrade, is especially nasty because in its attempt to upgrade the libmysqlclient18 and mysql-common packages, dpkg will REMOVE MariaDB.

MySQL 5.5 users are also affected in a similar way although the consequences look to be a bit lighter. Our early tests show for example that dist-upgrade will upgrade MySQL 5.5 to MySQL 5.6, which might come as a surprise. MySQL 5.5 users should therefore double-check how they are affected.

See below for examples of what these problems look like in practice. It is also worth noting that the problems do NOT exist if you are using MariaDB 10.0. With MariaDB 10.0 all the listed scenarios work just fine. MariaDB 10.0 is GA now and therefore a good alternative.

Solution

Fortunately there is a workaround that can be used and has been proven to work. By pinning the MariaDB repository you can override the normal behavior (where the highest version number wins). The process is simple. You only need to add a preferences file (with a .pref extension) for the MariaDB repository under the /etc/apt/preferences.d/ directory. The contents should look similar to the following:

$ cat /etc/apt/preferences.d/mariadb.pref
Package: *
Pin: origin ftp.osuosl.org
Pin-Priority: 1000

The value of Pin-Priority must be at least 1000. Also note that the Pin: row needs to have the domain name of the repository that you are using for your MariaDB apt sources file entry. In this example the domain is ftp.osuosl.org.

With the preference file in place the packages in the MariaDB repository will be preferred over the similarly named packages in the dotdeb repository and the problematic scenarios listed above will work just fine.

Many thanks to our users who promptly reported the problem on IRC, helped to find the root cause and experimented with the workaround!

Examples of the problematic scenarios

Scenario 1: Fresh installation or installation over a previous version of MariaDB 5.5
Result: Fails

$ sudo apt-get install mariadb-server mariadb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mariadb-client : Depends: mariadb-client-5.5 (= 5.5.36+maria-1~wheezy) but it is not going to be installed
mariadb-server : Depends: mariadb-server-5.5 (= 5.5.36+maria-1~wheezy) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Scenario 2: apt-get upgrade
Result: MariaDB server and client are not upgraded

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
libmariadbclient18 libmysqlclient18 mariadb-client mariadb-client-5.5 mariadb-client-core-5.5 mariadb-server
mariadb-server-5.5 mariadb-server-core-5.5 mysql-common
The following packages will be upgraded:
mariadb-common
1 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
Need to get 3,276 B of archives.
After this operation, 0 B of additional disk space will be used.

Scenario 3: apt-get dist-upgrade
Result: mariadb-server and mariadb-client are removed

$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
libmariadbclient18 mariadb-client mariadb-client-5.5 mariadb-client-core-5.5 mariadb-server mariadb-server-5.5
mariadb-server-core-5.5
The following packages will be upgraded:
libmysqlclient18 mysql-common
2 upgraded, 0 newly installed, 7 to remove and 0 not upgraded.
Need to get 1,210 kB of archives.
After this operation, 109 MB disk space will be freed.