Repository navigation
fix(dbserver): add --single-transaction and MySQL 9.5+ dump flags to export-db - #8797
Merged
Merged
Conversation
|
Download this PR's build for your OS and architecture with: ddev utility download-ddev --pr 8797Or download the artifact for your OS and architecture directly:
See Testing a PR. |
…export-db MySQL 9.5+ defaults gtid_mode to ON, which makes mysqldump emit GTID_PURGED warnings/statements on export-db's single-database dumps, and dumping users in containerized MySQL typically lack the PROCESS privilege CREATE TABLESPACE statements require. GetDBDumpCommand() now always adds --single-transaction for a consistent non-locking snapshot, and adds --set-gtid-purged=OFF and --no-tablespaces only when the detected MySQL version is >=9.5, gated on the version number so it keeps working for future 9.x releases.
rfay
force-pushed
the
20260902_rfay_mysql_97_export
branch
from
September 11, 2026 19:04
2adf1b8 to
c9a2b22
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Short Summary (TL;DR)
ddev export-dbnow passes--single-transactionon every MySQL/MariaDB version for a consistent non-locking dump, and on MySQL 9.5+ (currentlymysql:9.7) also passes--set-gtid-purged=OFFand--no-tablespacesso the export stays clean of GTID metadata and tablespace-privilege errors that MySQL 9.5+'s new defaults introduce.The Issue
MySQL 9.5 changed the default of
gtid_modetoON. Sinceexport-dbdumps a single project database (not--all-databases, and not for replication), mysqldump's default--set-gtid-purged=AUTObehavior on a GTID-enabled server produced this on every export:The dump still worked and re-imported fine with
import-db, so this wasn't a functional bug, but it was alarming noise on everyexport-dbrun against MySQL 9.7. Separately, mysqldump'sCREATE TABLESPACEstatements need thePROCESSprivilege, which the dumping user in a containerized MySQL setup typically doesn't have.How This PR Solves The Issue
GetDBDumpCommand()inpkg/ddevapp/ddevapp.gonow builds the dump command with flags instead of returning a bare binary name:--single-transactionis added unconditionally, for all MySQL and MariaDB versions, closing the second warning above and giving a consistent InnoDB snapshot without locking tables.--set-gtid-purged=OFFand--no-tablespacesare added only when the database is MySQL and the detected version is>= 9.5, using the existingutil.SemverValidatehelper rather than hardcoding9.7, so this keeps working automatically if DDEV adds a newer 9.x version later.--routines/--triggers/--eventsare unchanged;--triggerswas already mysqldump's default, and--routines/--eventswere never included inexport-db's single-database dumps at any version, so that's out of scope here.Manual Testing Instructions
mysql:9.7, runddev export-db -f dump.sql.gzand confirm the GTID/single-transaction warnings above no longer appear.ddev import-db -f dump.sql.gz.mysql:8.0) and on MariaDB, and confirm--set-gtid-purged/--no-tablespacesare not added (no behavior change there beyond the new--single-transaction).Automated Testing Overview
Added
TestGetDBDumpCommandinpkg/ddevapp/ddevapp_test.go, a unit test covering the flag set chosen for MySQL 8.0/8.4/9.4 (no gated flags), MySQL 9.5/9.7 (gated flags present), and MariaDB below/at/above the existing 10.5mariadb-dumpcutover.Release/Deployment Notes
export-dboutput changes for every user: the GTID/tablespace warnings on MySQL 9.5+ disappear, and--single-transactionis now always used. No config or CLI flag changes; no impact onimport-db.