From 4ab0025db3202f3cc08493c828e2879106c5666d Mon Sep 17 00:00:00 2001 From: Florian Haas Date: Fri, 13 Oct 2023 11:58:09 +0200 Subject: [PATCH] fix: Restore pre-Tutor 16 behavior, disable the MySQL binlog by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- changelog.d/20231013_114747_fghaas_disable_mysql_binlog.md | 1 + tutor/templates/config/defaults.yml | 1 + tutor/templates/k8s/deployments.yml | 6 +++++- tutor/templates/local/docker-compose.yml | 6 +++++- 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelog.d/20231013_114747_fghaas_disable_mysql_binlog.md diff --git a/changelog.d/20231013_114747_fghaas_disable_mysql_binlog.md b/changelog.d/20231013_114747_fghaas_disable_mysql_binlog.md new file mode 100644 index 0000000000..a2f4d06cd8 --- /dev/null +++ b/changelog.d/20231013_114747_fghaas_disable_mysql_binlog.md @@ -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) diff --git a/tutor/templates/config/defaults.yml b/tutor/templates/config/defaults.yml index 94f127226e..fb82b5708c 100644 --- a/tutor/templates/config/defaults.yml +++ b/tutor/templates/config/defaults.yml @@ -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" diff --git a/tutor/templates/k8s/deployments.yml b/tutor/templates/k8s/deployments.yml index ff833ad1ca..9a85e29f56 100644 --- a/tutor/templates/k8s/deployments.yml +++ b/tutor/templates/k8s/deployments.yml @@ -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 }}" diff --git a/tutor/templates/local/docker-compose.yml b/tutor/templates/local/docker-compose.yml index a2ace7c57b..2bef2f20fb 100644 --- a/tutor/templates/local/docker-compose.yml +++ b/tutor/templates/local/docker-compose.yml @@ -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: