Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken mysql after palm upgrade #890

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- 💥[Bugfix] Fix mysql crash after upgrade to Palm. After an upgrade to Palm, the mysql client run by Django defaults to a utf8mb4 character set and collation, but the mysql server still runs with utf8mb3. This causes broken data during migration from Olive to Palm, and more generally when data is written to the database. To resolve this issue, we explicitely set the utf8mb3 charset and collation in the client. Users who were running Palm might have to fix their data manually. In the future we will upgrade the mysql server to utf8mb4. (by @regisb)
- [Improvement] We upgrade to MySQL 8.1.0 to avoid having to restart the server after the upgrade.
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This configuration parameter defines which MongoDB Docker image to use.

.. https://hub.docker.com/_/mysql/tags?page=1&name=8.0

- ``DOCKER_IMAGE_MYSQL`` (default: ``"docker.io/mysql:8.0.33"``)
- ``DOCKER_IMAGE_MYSQL`` (default: ``"docker.io/mysql:8.1.0"``)

This configuration parameter defines which MySQL Docker image to use.

Expand Down
2 changes: 1 addition & 1 deletion tests/commands/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_images_pull_all_vendor_images(self, image_pull: Mock) -> None:
self.assertIsNone(result.exception)
self.assertEqual(0, result.exit_code)
# Note: we should update this tag whenever the mysql image is updated
image_pull.assert_called_once_with("docker.io/mysql:8.0.33")
image_pull.assert_called_once_with("docker.io/mysql:8.1.0")

def test_images_printtag_image(self) -> None:
result = self.invoke(["images", "printtag", "openedx"])
Expand Down
2 changes: 1 addition & 1 deletion tutor/commands/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def sqlshell(args: list[str]) -> t.Iterable[tuple[str, str]]:
Extra arguments will be passed to the `mysql` command verbatim. For instance, to
show tables from the "openedx" database, run `do sqlshell openedx -e 'show tables'`.
"""
command = "mysql --user={{ MYSQL_ROOT_USERNAME }} --password={{ MYSQL_ROOT_PASSWORD }} --host={{ MYSQL_HOST }} --port={{ MYSQL_PORT }}"
command = "mysql --user={{ MYSQL_ROOT_USERNAME }} --password={{ MYSQL_ROOT_PASSWORD }} --host={{ MYSQL_HOST }} --port={{ MYSQL_PORT }} --default-character-set=utf8mb3"
if args:
command += " " + shlex.join(args) # pylint: disable=protected-access
yield ("lms", command)
Expand Down
3 changes: 3 additions & 0 deletions tutor/templates/apps/openedx/config/partials/auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ DATABASES:
ATOMIC_REQUESTS: true
OPTIONS:
init_command: "SET sql_mode='STRICT_TRANS_TABLES'"
{%- if RUN_MYSQL %}
charset: "utf8mb3"
{%- endif %}
EMAIL_HOST_USER: "{{ SMTP_USERNAME }}"
EMAIL_HOST_PASSWORD: "{{ SMTP_PASSWORD }}"
2 changes: 1 addition & 1 deletion tutor/templates/config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ DOCKER_IMAGE_OPENEDX_DEV: "openedx-dev:{{ TUTOR_VERSION }}"
DOCKER_IMAGE_CADDY: "docker.io/caddy:2.6.4"
DOCKER_IMAGE_ELASTICSEARCH: "docker.io/elasticsearch:7.17.9"
DOCKER_IMAGE_MONGODB: "docker.io/mongo:4.4.22"
DOCKER_IMAGE_MYSQL: "docker.io/mysql:8.0.33"
DOCKER_IMAGE_MYSQL: "docker.io/mysql:8.1.0"
DOCKER_IMAGE_PERMISSIONS: "{{ DOCKER_REGISTRY }}overhangio/openedx-permissions:{{ TUTOR_VERSION }}"
DOCKER_IMAGE_REDIS: "docker.io/redis:7.0.11"
DOCKER_IMAGE_SMTP: "docker.io/devture/exim-relay:4.96-r1-0"
Expand Down
2 changes: 1 addition & 1 deletion tutor/templates/local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:
{% if RUN_MYSQL -%}
mysql:
image: {{ DOCKER_IMAGE_MYSQL }}
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
command: mysqld --character-set-server=utf8mb3 --collation-server=utf8mb3_general_ci
regisb marked this conversation as resolved.
Show resolved Hide resolved
restart: unless-stopped
user: "999:999"
volumes:
Expand Down