Skip to content

ddev import-db fails on dumps with utf8mb4_0900_ai_ci trailing-space unique keys #8242

@brandonlira

Description

@brandonlira

Preliminary checklist

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

  1. Use DDEV v1.25.1.
  2. Start a project using MySQL 8.0.
  3. Use a dump containing a table created with utf8mb4_0900_ai_ci.
  4. Ensure that table contains rows that differ only by trailing whitespace in a PK/unique key, for example:
    ('/ecosse/edimbourg','fr',...)
    ('/ecosse/edimbourg ','fr',...)
  5. 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
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions