Repository navigation
feat: an upgrade moves the database to MySQL 9.7 LTS safely - #25
Merged
Merged
Conversation
When the new compose file runs a MySQL line without mysql_native_password (8.4.x to 9.7.x), the upgrade asks the running database which users still sign in with it, moves root and the app's user to caching_sha2_password with their passwords from the .env, and takes the mysql_native_password line out of data/mysql/my.cnf. Any other user on it stops the upgrade before anything changes, with the ALTER USER command to run by hand. A rollback puts my.cnf back and, once the new MySQL started, moves its data aside so the old MySQL starts on a new folder with the backup loaded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The docker setup now runs MySQL 9.7 LTS (ansibleforms/docker#50), and MySQL 9 removed the
mysql_native_passwordplugin: a server whosemy.cnfstill setsmysql_native_password=ONrefuses to start, and a user still on that plugin can no longer sign in. A compose upgrade replaceddocker-compose.ymlbut kept the olddata/mysql/my.cnf, so an upgraded install would not have come back up.When the new compose file's
mysqldbimage is a higher MySQL line without the plugin (8.4.x to 9.7.x; a patch of the same line such as 8.4.11 to 8.4.13 or 9.7 to 9.7.5 is not), the upgrade now does this while the current MySQL still runs:mysql_native_password, throughcompose exec -T mysqldbas root withMYSQL_PWD, as the backup's dump does. The review says the database moves from MySQL 8.4.x to 9.7.x.MYSQLDB_USER) stops the upgrade before anything changes. The message lists them with theALTER USERcommand to run by hand. The users are asked again right before the backup.caching_sha2_passwordwith their passwords from the.env. The SQL goes on mysql's standard input, never on a command line, and passwords are scrubbed from any error.mysql_native_passwordline goes fromdata/mysql/my.cnf(any case or spacing,_or-). The other lines stay, and the old file is saved asmy.cnf.<version>.bak.Rollback: it puts
my.cnfback. The moved users are harmless on 8.4, which hascaching_sha2_passwordtoo. 8.4 cannot start on data that 9.7 already upgraded, so once the new containers were started, the rollback stopsmysqldband moves the data folder aside (data/mysql/db.<mysql version>.<time>). The old MySQL then starts on a new folder and the backup is loaded into it.The Helm path (
internal/kube) is untouched: the chart'smy.cnfnever set the line, and the chart handles its own MySQL.What an operator sees
An upgrade with only root and the app's user on the plugin shows one more review paragraph and two more steps:
When another user is on the plugin, the upgrade stops with nothing changed:
Every new text is in all eleven languages.
Tests
The tests use table tests and a fake
mysqlRun. They cover:my.cnfedit and its restore;ALTERof the known users;I also checked the query, the batch escapes and the
ALTERwith an escaped password against a realmysql:8.4container.Checklist
<type>/<description>and the title is a Conventional Commitgofmt -l .prints nothing, andgo vet ./...andgo test ./...passinternal/i18n/locales