Fix compatibility with MariaDB 12 (and future versions)#939
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Warden environment DB service definitions to improve compatibility with newer MariaDB images (e.g., MariaDB 12) by no longer hardcoding the server binary (mysqld) in compose command: arrays, relying instead on the image entrypoint behavior when the first argument is an option.
Changes:
- Removed explicit
mysqldfrom several environment DB servicecommand:lists so the container entrypoint can select the correct server binary. - Updated Magento split DB and test DB service definitions to follow the same pattern.
- Added an UNRELEASED changelog entry referencing the fix for #864.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| environments/magento2/magento2.tests.base.yml | Removes explicit mysqld from tmp DB command so entrypoint can choose the correct binary. |
| environments/magento2/magento2.splitdb.sales.base.yml | Removes explicit mysqld from sales split DB service command. |
| environments/magento2/db.base.yml | Removes explicit mysqld from main Magento 2 DB service command. |
| environments/magento1/db.base.yml | Removes explicit mysqld from Magento 1 DB service command. |
| environments/drupal/db.base.yml | Removes explicit mysqld from Drupal DB service command. |
| environments/cakephp/db.base.yml | Removes explicit mysqld from CakePHP DB service command. |
| CHANGELOG.md | Notes the fix in the UNRELEASED “Bug Fixes” section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5bb450e to
23a39d4
Compare
|
Noticed the the |
0e1ea88 to
a03dbfe
Compare
The entrypoint script in the MySQL/MariaDB images automatically prepend the correct binary name to the command if the first argument starts with the "-" character. Since MariaDB removed the MySQL compatibility symlinks from their Docker images, the previous "mysql" command started failing. This commit removes the explicit command name from the DB service definitions, since the entrypoints (in both MySQL and MariaDB images) are smart enough to prepend the correct command if we just supply the arguments.
MariaDB stopped including the `mysql` symlinks in the official Docker images, so now the commands using `mysql` or `mysqldump` are failing with newer MariaDB versions. This commit adds logic to determine the appropriate commands to use based on the MYSQL_DISTRIBUTION (as that was already used previously for the `warden db upgrade` subcommand). However, it seems like the upgrade subcommand has never worked! The MYSQL_ variables are exctracted from the DB containter environment variables, but the MYSQL_DISTRIBUTION was never added as an environment variable in the DB containers. Running the upgrade command results in the following: ERROR: The upgrade command only supports MySQL and MariaDB installations. This commit changes the DB services to include the MYSQL_DISTRIBUTION in the environment variables, so it can be used in the warden commands as intended(?).
a03dbfe to
8b7b8b5
Compare
| case "${MYSQL_DISTRIBUTION}" in | ||
| mariadb) | ||
| clientCmd="mariadb" | ||
| dumpCmd="mariadb-dump" | ||
| ;; | ||
| *) | ||
| clientCmd="mysql" | ||
| dumpCmd="mysqldump" | ||
| ;; | ||
| esac |
There was a problem hiding this comment.
This is backwards compatible to how it worked previously. Not in the scope to change that, unless requested by the maintainers.
mysql from DB service commands (fixes compatibility with MariaDB 12)
Issue
Trying to use MariaDB 12 in a Magento project caused the
db(andtmp-mysql) service to fail with the following error:This is due to MariaDB removing the mysql compatibility symlinks from their Docker images by default.
In addition the
warden dbcommands do not work, for the same reason.This was previously fixed in wardenenv/images#50 by explicitly installing the MySQL compatibility packages if the MariaDB version was 11. However, that fix does not work when using 12 (12.3 is the suggested version for newer Magento releases).
We could fix the issue by always installing the compatibility packages (instead of just for MariaDB 11). This PR offers a different approach.
Steps to reproduce
A Magento 2 environment with this configuration for the DB.
Proposed Fix
Services
For the DB services we can let the container entrypoint script to determine the correct command, instead of providing an explicit one.
Inspecting even older MySQL/MariaDB image entrypoint scripts
show that they all (that I spot checked, at least) have this kind of snippet in the beginning of the main part of the script
So we do not actually need to provide the explicit command at all, but the container can decide what command to use.
Commands
The
dbcommand has previously used theMYSQL_DISTRIBUTIONenvironment variable for deciding which DB upgrade command to use.This PR changes the command to do the same also for the client and dump commands.
Using MYSQL_DISTRIBUTION
I don't know if the
warden db upgradecommand has ever worked, as theMYSQL_variables are read from the container's environment variables, and theMYSQL_DISTRIBUTIONwas never added there. In testing the command just failed for me.This PR fixes that issue by including the MYSQL_DISTRIBUTION in the DB container environment, though that feels a tad hacky to be honest.