liip / LiipTestFixturesBundle

This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications
https://liip.ch
MIT License
165 stars 45 forks source link

[Bug]: mysqldump: unknown variable 'column-statistics=0' error #251

Closed ahmad-rahnavard closed 8 months ago

ahmad-rahnavard commented 9 months ago

Preconditions

PHP: 8.1.25 Symfony: 5.4 LiipTestFixturesBundle: 2.6.0 DB: mariadb:10.5 (docker container with exposed port)

Steps to reproduce

The bundle config:

liip_test_fixtures:
    keep_database_and_schema: false
    cache_metadata: true
    cache_db:
        mysql: 'Liip\TestFixturesBundle\Services\DatabaseBackup\MysqlDatabaseBackup'

Expected result

Tests should run without any issues and faster than when you set cache_db: ~

Actual result

Getting the following error in tests. which also results in some failing tests.

mysqldump: unknown variable 'column-statistics=0'

NOTE: When I run the tests separately, I don't see any issues, but running multiple tests together results in the error above.

Removing the --column-statistics=0 option from this line https://github.com/liip/LiipTestFixturesBundle/blob/2.x/src/Services/DatabaseBackup/MysqlDatabaseBackup.php#L78 fixed the issue for me.

alexislefebvre commented 9 months ago

Thanks for the report. What version of mysqldump is used?

This parameter was added in

ahmad-rahnavard commented 9 months ago

I appreciate the information. I understand the reason behind adding it. The version I'm using is:

mysqldump  Ver 10.19 Distrib 10.5.21-MariaDB, for debian-linux-gnu (x86_64)
alexislefebvre commented 9 months ago

Could you please explain how did you install mysqldump? This bundle will have to support different versions of this tool if we want the backups to work. :grimacing:

ahmad-rahnavard commented 9 months ago

I installed it using apt-get install default-mysql-client in a Docker container based on the official php:8.1-fpm-bullseye image.

alexislefebvre commented 8 months ago

The mysqldump provided by MariaDB doesn't support this option:

docker run --rm -it php:8.1-fpm-bullseye bash -c "apt update && apt install -y -q default-mysql-client && mysqldump --version && mysqldump --column-statistics=0"
# […]
mysqldump  Ver 10.19 Distrib 10.5.21-MariaDB, for debian-linux-gnu (x86_64)
mysqldump: unknown variable 'column-statistics=0'

Please try the following change, I tried to keep compatibility with MySQL and MariaDB:

ahmad-rahnavard commented 8 months ago

I can confirm that the proposed changes will resolve the issue, and it should work fine. Thank you @alexislefebvre :pray:

alexislefebvre commented 8 months ago

Thanks! It was published in the last release: https://github.com/liip/LiipTestFixturesBundle/releases/tag/2.7.1