From 96542304fc0449453e492457bd99bd33050770dd Mon Sep 17 00:00:00 2001 From: linus-liu-web <395141741@qq.com> Date: Sun, 22 Nov 2026 01:57:51 +0800 Subject: [PATCH] fix(compose): bound the bundled MySQL binary log The default Compose stack starts MySQL with binary logging on and no retention, so every checkpoint, telemetry and log row is also written to the binlog without an upper bound. A write storm then fills loopforge_mysql-data with binary logs while the database itself stays small: #1138 reported 298 GB of binlogs in four days while the largest table was 0.16 GB, and a Compose deployment here accumulated 1.18 GB of binlogs in about a day. Bound the log instead of leaving it unbounded: - --binlog-expire-logs-seconds=86400 keeps one day of binary logs; - --max-binlog-size=67108864 rotates every 64 MiB. Deployments that need point-in-time recovery or replication can raise or drop the two flags; single-node evaluation stacks can pass --skip-log-bin. Document both, plus the PURGE BINARY LOGS command for installations that already accumulated logs. --- compose.yaml | 10 +++++++++- docs/deployment.md | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 4710f3d2..08bd34f1 100644 --- a/compose.yaml +++ b/compose.yaml @@ -7,7 +7,15 @@ services: MYSQL_USER: loopforge MYSQL_PASSWORD: ${LOOPFORGE_DB_PASSWORD:?Run scripts/configure.sh first} MYSQL_ROOT_PASSWORD: ${LOOPFORGE_DB_ROOT_PASSWORD:?Run scripts/configure.sh first} - command: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"] + # The platform keeps writing checkpoint, telemetry and log rows, and every + # write is logged; bound the binary log so a runaway writer cannot fill the + # data volume. Raise or drop these flags when point-in-time recovery or + # replication is required. + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + - --binlog-expire-logs-seconds=86400 + - --max-binlog-size=67108864 ports: - "127.0.0.1:${LOOPFORGE_MYSQL_PORT:-33315}:3306" volumes: diff --git a/docs/deployment.md b/docs/deployment.md index 693cb9d6..87ff5cd9 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -65,6 +65,13 @@ Run it as the installation owner, including an ordinary Linux user. If that user `compose.yaml` is the published-image stack and never builds: `./start.sh`, `scripts/install.sh` and a plain `docker compose --profile platform up` all pull the GHCR release pinned there (currently `ghcr.io/tencent/loopforge:0.4.0`). The pin matches the checkout's migrations and seeds, so check out a release tag when you install. Set `LOOPFORGE_IMAGE` (for example to an `@sha256:` digest) only to override it; a value saved in `.env` takes precedence over later pin changes. +The bundled `mysql:8.4` keeps its binary log bounded: `compose.yaml` starts it with `--binlog-expire-logs-seconds=86400` and `--max-binlog-size=67108864`, so an unexpected write storm cannot fill `loopforge_mysql-data` with binary logs (the platform writes checkpoint, telemetry and log rows continuously, and every write is logged). Deployments that need point-in-time recovery or replication can raise those values or remove the two flags; single-node evaluation installations that need no recovery can pass `--skip-log-bin` to stop binary logging entirely. To reclaim logs already written by an older Compose stack, run: + +```bash +docker compose exec -T mysql sh -c 'MYSQL_PWD="$MYSQL_ROOT_PASSWORD" mysql -u root -e "PURGE BINARY LOGS BEFORE NOW()"' +docker compose exec -T mysql sh -c 'MYSQL_PWD="$MYSQL_ROOT_PASSWORD" mysql -u root -e "SET PERSIST binlog_expire_logs_seconds=86400"' +``` + To upgrade, update the checkout first, then refresh the containers: ```bash