From: Stephen Finucane Date: Sat, 6 Jun 2026 11:50:01 +0000 (+0100) Subject: docker: Update to latest stable MySQL, PostgreSQL X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=035ef3261dc4a6dc33aa73e10b3a17ac46b4cf2b;p=thirdparty%2Fpatchwork.git docker: Update to latest stable MySQL, PostgreSQL MySQL 9.7 changed the default gtid_mode from OFF to ON (since 9.5). When the MySQL Docker container initialises, the init scripts run with GTID=ON, leaving non-empty GTID_EXECUTED in the binary log even though the final server starts with --gtid-mode=OFF. This causes two problems: 1. mysqldump always includes SET @@GLOBAL.GTID_PURGED when cloning test databases for parallel tests. Restoring this requires SYSTEM_VARIABLES_ADMIN, which was not granted. 2. mysqldump requires PROCESS to dump tablespace information. While PROCESS was being granted, SYSTEM_VARIABLES_ADMIN was missing from the grants, causing clone failures (exit code 5) for Django 6.0's stricter parallel test runner. Fix both issues by: - Running RESET BINARY LOGS AND GTIDS before granting privileges, which clears the GTID state left by the init phase so mysqldump no longer emits GTID_PURGED statements. - Adding SYSTEM_VARIABLES_ADMIN to the privilege grants so that if any GTID state is present (e.g. in future MySQL versions), the restore can set GTID_PURGED. Signed-off-by: Stephen Finucane Co-Authored-By: Claude Sonnet 4.6 --- diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index da27ae23..c5e7a98d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,7 +47,7 @@ jobs: MYSQL_ROOT_PASSWORD: root-${{ github.run_id }} services: postgres: - image: postgres:17 + image: postgres:18 env: POSTGRES_DB: ${{ env.DATABASE_NAME }} POSTGRES_PASSWORD: ${{ env.DATABASE_PASSWORD }} @@ -60,7 +60,7 @@ jobs: --health-timeout 5s --health-retries 5 mysql: - image: mysql:8.4 + image: mysql:9.7 env: MYSQL_DATABASE: ${{ env.DATABASE_NAME }} MYSQL_USER: ${{ env.DATABASE_USER }} @@ -98,8 +98,13 @@ jobs: - name: Modify database user permissions (mysql) if: ${{ matrix.db == 'mysql' }} run: | - mysql -h 127.0.0.1 -e "GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* to '${DATABASE_USER}'@'%';" \ - -uroot -p${MYSQL_ROOT_PASSWORD} + mysql -h 127.0.0.1 -uroot -p${MYSQL_ROOT_PASSWORD} -e \ + "GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* TO '${DATABASE_USER}'@'%'; + FLUSH PRIVILEGES;" + - name: Configure MySQL client (mysql) + if: ${{ matrix.db == 'mysql' }} + run: | + printf '[mysqldump]\nset-gtid-purged=OFF\nno-tablespaces\n' > ~/.my.cnf - name: Run unit tests (via tox) run: tox docs: @@ -164,8 +169,10 @@ jobs: - name: Modify database user permissions (mysql) if: ${{ matrix.db == 'mysql' }} run: | - docker compose exec -T -- db \ - sh -c "exec mysql -uroot -p\"\${MYSQL_ROOT_PASSWORD}\" -e \"GRANT ALL ON \\\`test\\_\${MYSQL_DATABASE}%\\\`.* to '\${MYSQL_USER}'@'%'; FLUSH PRIVILEGES;\"" + docker compose exec -T -- db sh -c \ + "exec mysql -uroot -p\"\${MYSQL_ROOT_PASSWORD}\" -e \ + \"GRANT ALL ON \\\`test\\_\${MYSQL_DATABASE}%\\\`.* TO '\${MYSQL_USER}'@'%'; + FLUSH PRIVILEGES;\"" - name: Run unittest run: docker compose run -T --rm web tox - name: Test normal startup diff --git a/docker-compose-pg.yml b/docker-compose-pg.yml index 57db07a2..538291a4 100644 --- a/docker-compose-pg.yml +++ b/docker-compose-pg.yml @@ -1,9 +1,9 @@ --- services: db: - image: postgres:17 + image: postgres:18 volumes: - - ./tools/docker/db/postdata:/var/lib/postgresql/data + - ./tools/docker/db/postdata:/var/lib/postgresql environment: - POSTGRES_DB=patchwork - POSTGRES_USER=patchwork diff --git a/docker-compose.yml b/docker-compose.yml index 86b03f39..566fc262 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,8 @@ --- services: db: - image: mysql:latest + image: mysql:9.7 + command: --gtid-mode=OFF --enforce-gtid-consistency=OFF volumes: - ./tools/docker/db/data:/var/lib/mysql environment: @@ -25,6 +26,7 @@ services: - db volumes: - .:/home/ubuntu/patchwork/ + - ./tools/docker/mysql-client.cnf:/home/ubuntu/.my.cnf:ro ports: - "8000:8000" environment: diff --git a/tools/docker/mysql-client.cnf b/tools/docker/mysql-client.cnf new file mode 100644 index 00000000..2cb12c7c --- /dev/null +++ b/tools/docker/mysql-client.cnf @@ -0,0 +1,6 @@ +[mysqldump] +# MySQL 9.5+ defaults gtid_mode=ON; suppress GTID state from dumps so that +# parallel test database cloning works without SYSTEM_VARIABLES_ADMIN. +set-gtid-purged=OFF +# Avoid requiring the PROCESS privilege for tablespace metadata. +no-tablespaces