]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
docker: Update to latest stable MySQL, PostgreSQL
authorStephen Finucane <stephen@that.guru>
Sat, 6 Jun 2026 11:50:01 +0000 (12:50 +0100)
committerStephen Finucane <stephenfinucane@hotmail.com>
Sun, 7 Jun 2026 15:10:53 +0000 (16:10 +0100)
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 <stephen@that.guru>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
.github/workflows/ci.yaml
docker-compose-pg.yml
docker-compose.yml
tools/docker/mysql-client.cnf [new file with mode: 0644]

index da27ae2337e8e3a39994d6e88960f48bb6e869ae..c5e7a98d15c46251fc6470b9f6b8a541fc2c12ce 100644 (file)
@@ -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
index 57db07a24898f145fc8cc4ca2a816ce6db4e1482..538291a477b095b0b705479c0ead52d4d5c87e05 100644 (file)
@@ -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
index 86b03f394d3c23801577248c6cd8fc5184c4d9bd..566fc2626a65530c95423a329c32a9f246db0ed7 100644 (file)
@@ -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 (file)
index 0000000..2cb12c7
--- /dev/null
@@ -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