-
-
Notifications
You must be signed in to change notification settings - Fork 701
ddev import-db fails on dumps with utf8mb4_0900_ai_ci trailing-space unique keys #8242
Description
Preliminary checklist
- I am using the latest stable version of DDEV (see upgrade guide)
- I have searched existing issues
- I have checked the troubleshooting guide
- I have run
ddev utility testor at leastddev utility diagnoseto include output below
Output of ddev utility test or ddev utility diagnose
Expand `ddev utility test` diagnostic information
DDEV Diagnostic Report
======================
Environment
===========
ℹ DDEV version: v1.25.1
ℹ OS: Linux x86_64
ℹ Distro: Ubuntu 24.04.2 LTS
ℹ Shell: /usr/bin/zsh
ℹ Docker provider: linux-docker
ℹ Docker version: 28.3.2
Docker Environment
==================
✓ Docker is running
✓ Docker disk space: 66% used
✓ Can run containers with volume mounts
✓ Internet access from containers
✓ Docker buildx working
✓ Docker authentication configured
Network Connectivity
====================
✓ Internet accessible from host
✓ DNS resolves *.ddev.site
HTTPS/mkcert
============
✓ mkcert is installed: v1.4.4
✓ mkcert CA certificates exist
Current Project
===============
ℹ Name: my-project
ℹ Type: drupal10
ℹ Status: running
✓ No custom configurations detected
ℹ Installed add-ons (2):
ℹ - memcached
ℹ - solr
✓ Project containers are responsive
Expected Behavior
ddev import-db should import the dump successfully. The same dump imports correctly when run directly through the MySQL client, and the table-level collation allows the relevant values to coexist.
Actual Behavior
On DDEV v1.25.1, ddev import-db fails with a duplicate key error during import.
Example error:
ERROR 1062 (23000) at line 28442: Duplicate entry '/ecosse/edimbourg -fr' for key 'redirect_404.PRIMARY'
The dump contains both of these values in redirect_404:
('/ecosse/edimbourg','fr',143,0,1771945569,0),
('/ecosse/edimbourg ','fr',39,0,1766907536,0),
Importing the exact same dump directly with:
ddev mysql db < dump.sql
Steps To Reproduce
Steps To Reproduce
- Use DDEV
v1.25.1. - Start a project using MySQL 8.0.
- Use a dump containing a table created with
utf8mb4_0900_ai_ci. - Ensure that table contains rows that differ only by trailing whitespace in a PK/unique key, for example:
('/ecosse/edimbourg','fr',...) ('/ecosse/edimbourg ','fr',...)
- Run:
ddev import-db --file=dump.sql.gz
6.Observe the duplicate key import failure.
7.Import the same dump with:gzip -cd dump.sql.gz | ddev mysql db - Observe that the direct MySQL import succeeds.
Anything else?
Anything else?
This started reproducing for us after updating from DDEV v1.24.4 to v1.25.1.
A likely related change in the DDEV release notes is:
fix(import-db): replace modern collations with server default
This appears to affect dumps where modern collations such as utf8mb4_0900_ai_ci are important to keep values distinct during import.
We’ve also seen a similar failure on another project with a different unique key (users_field_data.user_name), where the underlying cause was trailing spaces in the stored value. That suggests this is not isolated to a single table or codebase, but may affect any dump where values remain distinct under the original collation and then collide during ddev import-db.