Skip to content

Commit 035ef32

Browse files
stephenfinclaude
andcommitted
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 <stephen@that.guru> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ff03daf commit 035ef32

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
MYSQL_ROOT_PASSWORD: root-${{ github.run_id }}
4848
services:
4949
postgres:
50-
image: postgres:17
50+
image: postgres:18
5151
env:
5252
POSTGRES_DB: ${{ env.DATABASE_NAME }}
5353
POSTGRES_PASSWORD: ${{ env.DATABASE_PASSWORD }}
@@ -60,7 +60,7 @@ jobs:
6060
--health-timeout 5s
6161
--health-retries 5
6262
mysql:
63-
image: mysql:8.4
63+
image: mysql:9.7
6464
env:
6565
MYSQL_DATABASE: ${{ env.DATABASE_NAME }}
6666
MYSQL_USER: ${{ env.DATABASE_USER }}
@@ -98,8 +98,13 @@ jobs:
9898
- name: Modify database user permissions (mysql)
9999
if: ${{ matrix.db == 'mysql' }}
100100
run: |
101-
mysql -h 127.0.0.1 -e "GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* to '${DATABASE_USER}'@'%';" \
102-
-uroot -p${MYSQL_ROOT_PASSWORD}
101+
mysql -h 127.0.0.1 -uroot -p${MYSQL_ROOT_PASSWORD} -e \
102+
"GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* TO '${DATABASE_USER}'@'%';
103+
FLUSH PRIVILEGES;"
104+
- name: Configure MySQL client (mysql)
105+
if: ${{ matrix.db == 'mysql' }}
106+
run: |
107+
printf '[mysqldump]\nset-gtid-purged=OFF\nno-tablespaces\n' > ~/.my.cnf
103108
- name: Run unit tests (via tox)
104109
run: tox
105110
docs:
@@ -164,8 +169,10 @@ jobs:
164169
- name: Modify database user permissions (mysql)
165170
if: ${{ matrix.db == 'mysql' }}
166171
run: |
167-
docker compose exec -T -- db \
168-
sh -c "exec mysql -uroot -p\"\${MYSQL_ROOT_PASSWORD}\" -e \"GRANT ALL ON \\\`test\\_\${MYSQL_DATABASE}%\\\`.* to '\${MYSQL_USER}'@'%'; FLUSH PRIVILEGES;\""
172+
docker compose exec -T -- db sh -c \
173+
"exec mysql -uroot -p\"\${MYSQL_ROOT_PASSWORD}\" -e \
174+
\"GRANT ALL ON \\\`test\\_\${MYSQL_DATABASE}%\\\`.* TO '\${MYSQL_USER}'@'%';
175+
FLUSH PRIVILEGES;\""
169176
- name: Run unittest
170177
run: docker compose run -T --rm web tox
171178
- name: Test normal startup

docker-compose-pg.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
services:
33
db:
4-
image: postgres:17
4+
image: postgres:18
55
volumes:
6-
- ./tools/docker/db/postdata:/var/lib/postgresql/data
6+
- ./tools/docker/db/postdata:/var/lib/postgresql
77
environment:
88
- POSTGRES_DB=patchwork
99
- POSTGRES_USER=patchwork

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
services:
33
db:
4-
image: mysql:latest
4+
image: mysql:9.7
5+
command: --gtid-mode=OFF --enforce-gtid-consistency=OFF
56
volumes:
67
- ./tools/docker/db/data:/var/lib/mysql
78
environment:
@@ -25,6 +26,7 @@ services:
2526
- db
2627
volumes:
2728
- .:/home/ubuntu/patchwork/
29+
- ./tools/docker/mysql-client.cnf:/home/ubuntu/.my.cnf:ro
2830
ports:
2931
- "8000:8000"
3032
environment:

tools/docker/mysql-client.cnf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[mysqldump]
2+
# MySQL 9.5+ defaults gtid_mode=ON; suppress GTID state from dumps so that
3+
# parallel test database cloning works without SYSTEM_VARIABLES_ADMIN.
4+
set-gtid-purged=OFF
5+
# Avoid requiring the PROCESS privilege for tablespace metadata.
6+
no-tablespaces

0 commit comments

Comments
 (0)