Skip to content

Commit

Permalink
fix: Restore pre-Tutor 16 behavior, disable the MySQL binlog by default
Browse files Browse the repository at this point in the history
Up to Tutor 15, when Tutor was configured with `RUN_MYSQL: true`, it
ran MySQL 5.7, which disabled binary logging ("the binlog") by default
unless enabled with the `--log-bin` option.

In Tutor 16, we switched to MySQL 8 which flipped this default: now,
the binlog is enabled by default, unless disabled with
`--skip-log-bin` or `--disable-log-bin`.

The binlog is relevant for two purposes:

1. MySQL replication.
2. Point-in-time restore (that is, incrementally rolling forward from
the most recently restored full backup, using binlog data).

However, in case neither of those purposes are relevant to the Tutor
deployment at hand (and it stands to reason that in most deployments
they are not), enabling the binlog comes with disadvantages:

* In busy Open edX databases, the binlog files can grow to
  considerable size, particularly considering the default expiry
  period for the binlog is a whopping 30 days.
* This can cause a MySQL volume to fill up and then disable the
  database altogether, because it runs into `ENOSPC` ("no space left
  on device") errors.
* This is especially true in `tutor k8s` configurations, where the
  MySQL volume size is just 5 GiB by default.

Thus, restore the pre-Tutor 16 behavior of running without the binlog
by default, and give users the opportunity to enable it by setting
`MYSQL_ENABLE_BINLOG: true`.

Reference:
https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html#option_mysqld_log-bin
  • Loading branch information
fghaas committed Oct 17, 2023
1 parent a7dd62b commit 4ab0025
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/20231013_114747_fghaas_disable_mysql_binlog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Bugfix] Default to running MySQL 8 in a standalone configuration without [binary logging](https://dev.mysql.com/doc/refman/8.0/en/binary-log.html), as we did in Tutor 15 with MySQL 5.7. If you do need binary logging because you are running [MySQL replication](https://dev.mysql.com/doc/refman/8.0/en/replication.html), or you want to be able to do [point-in-time recovery using the binlog](https://dev.mysql.com/doc/refman/8.0/en/point-in-time-recovery-binlog.html), set `MYSQL_ENABLE_BINLOG: true` in `config.yml`. (by @fghaas)
1 change: 1 addition & 0 deletions tutor/templates/config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ OPENEDX_MYSQL_USERNAME: "openedx"
OPENEDX_COMMON_VERSION: "open-release/palm.3"
OPENEDX_EXTRA_PIP_REQUIREMENTS:
- "openedx-scorm-xblock>=16.0.0,<17.0.0"
MYSQL_ENABLE_BINLOG: false
MYSQL_HOST: "mysql"
MYSQL_PORT: 3306
MYSQL_ROOT_USERNAME: "root"
Expand Down
6 changes: 5 additions & 1 deletion tutor/templates/k8s/deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@ spec:
containers:
- name: mysql
image: {{ DOCKER_IMAGE_MYSQL }}
args: ["mysqld", "--character-set-server=utf8mb3", "--collation-server=utf8mb3_general_ci"]
args:
- "mysqld"
- "--character-set-server=utf8mb3"
- "--collation-server=utf8mb3_general_ci"
{% if not MYSQL_ENABLE_BINLOG -%}- "--disable-log-bin" {%- endif %}
env:
- name: MYSQL_ROOT_PASSWORD
value: "{{ MYSQL_ROOT_PASSWORD }}"
Expand Down
6 changes: 5 additions & 1 deletion tutor/templates/local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ services:
{% if RUN_MYSQL -%}
mysql:
image: {{ DOCKER_IMAGE_MYSQL }}
command: mysqld --character-set-server=utf8mb3 --collation-server=utf8mb3_general_ci
command: >
mysqld
--character-set-server=utf8mb3
--collation-server=utf8mb3_general_ci
{% if not MYSQL_ENABLE_BINLOG -%}--disable-log-bin{%- endif %}
restart: unless-stopped
user: "999:999"
volumes:
Expand Down

0 comments on commit 4ab0025

Please sign in to comment.