Skip to content

Commit

Permalink
fix: broken mysql after palm upgrade
Browse files Browse the repository at this point in the history
This fix is for a rather serious issue that affects users who upgrade
from Olive to Palm. The client mysql charset and collation was
incorrectly set to utf8mb4, while the server stil runs utf8mb3. Only
users who run the mysql container are affected.

To resolve this issue, we explicitely configure the client to use the
utf8mb3 charset/collation.

Important note: users who have somehow managed to upgrade from olive to
Palm before may find themselves in an undefined state. They might have
to fix their mysql data manually. Same thing for users who launched Palm
from scratch; although, according to my preliinary tests, they should be
able to downgrade their connection from utf8mb4 to utf8mb3 without
issue.

Close #887.
  • Loading branch information
regisb committed Aug 15, 2023
1 parent f6507f9 commit f70f84f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- 💥[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)
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/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
restart: unless-stopped
user: "999:999"
volumes:
Expand Down

0 comments on commit f70f84f

Please sign in to comment.