Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel uses --column-statistics=0 with MariaDB #43530

Closed
direc85 opened this issue Aug 3, 2022 · 4 comments
Closed

Laravel uses --column-statistics=0 with MariaDB #43530

direc85 opened this issue Aug 3, 2022 · 4 comments

Comments

@direc85
Copy link

direc85 commented Aug 3, 2022

  • Laravel Version: 8.83.23 (but it looks like it exist in Laravel 9, too)
  • PHP Version: 8.1.2
  • Database Driver & Version: 10.19 Distrib 10.6.7-MariaDB

Description:

artisan schema:dump (and some migrations) generates the dump, but produces the following warning:

mysqldump: unknown variable 'column-statistics=0'

Steps To Reproduce:

I was running Laravel in a Docker container with Ubuntu 21.04, PHP 7.4 and MariaDB 10.3. I then updated the docker config files to kick it to Ubuntu 22.04, PHP 8.1 and MariaDB 10.6. After upgrading the database using mysql_upgrade I started to poke the system to see what works and what doesn't. The first thing I tried was artisan schema:dump and it worked, but it produced the error message above.

So, I guess the steps to reproduce are either:

  1. Setup Ubuntu 21.04 with PHP 7.4 and MariaDB 10.3
  2. Install Laravel 8 with MariaDB
  3. Update to Ubuntu 22.04 with PHP 8.1 and MariaDB 10.6
  4. Upgrade the database
  5. artisan schema:dump

Or simply:

  1. Setup Ubuntu 22.04 with PHP 8.1 and MariaDB 10.6
  2. Install Laravel 8 with MariaDB
  3. artisan schema:dump

I also found #34442 which fixed the issue back in 2020 by inserting --column-statistics=0 only if the connection is not MariaDB, but the change has been edited out at some point. The function baseDumpCommand() is identical in master, 8.x and 9.x branches, and thus I considered this bug report still valid, although I am still at Laravel 8 (I will be updating to Laravel 9 soon, I hope.)

I then fixed the issue for myself by editing vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlSchemaState.php as follows:

protected function baseDumpCommand()
{
    $command = 'mysqldump '.$this->connectionString().' --no-tablespaces --skip-add-locks --skip-comments --skip-set-charset --tz-utc';

    if (! $this->connection->isMaria()) {
        $command .= ' --set-gtid-purged=OFF --column-statistics=0';
    }

    return $command.' "${:LARAVEL_LOAD_DATABASE}"';
}

One unknown in this equation for me is that why mysqldump 10.3 didn't complain about this, but 10.6 now does.

Thanks!

@direc85
Copy link
Author

direc85 commented Aug 3, 2022

Okay, it looks like Laravel 8.83.19 has #43027 which explicitly reverts this, but that makes the warning appear for me. I updated Composer packages before running the first artisan command, the current version is 8.83.23, and I am now affected.

Also, in #43027 the affected setup us using Sail, whereas I'm not. These two seem to behave differently in this context. I think the underlaying issue is somewhere there (artisan vs. sail).

Edit: According to Docker Hub, image: 'mariadb:10 installs 10.8, but it still doesn't support the flag; I tested this locally on my Manjaro workstation:

> mysqldump --version
mysqldump  Ver 10.19 Distrib 10.8.3-MariaDB, for Linux (x86_64)
> mysqldump --column-statistics=0
mysqldump: unknown variable 'column-statistics=0'

This contradicts #43027 as even MariaDB 10.8 doesn't support the flag... I'm getting flummoxed here!

@driesvints
Copy link
Member

I think right now, if things work with our own Docker provider (Sail) that we won't take an action to remove that flag if it risks breaking things again. If you figure out a way that solves this without breaking Sail then we'd be happy to receive a PR to 9.x. Sorry.

@direc85
Copy link
Author

direc85 commented Aug 5, 2022

Thanks for the reply. It's a Sail issue, as it always installs mysql-client even if only MariaDB is installed. I'll try to figure out how to properly solve the issue, but that's going to happen sometime next week, I think.

@direc85
Copy link
Author

direc85 commented Aug 19, 2022

It's not the mariadb-client installation that breaks the command (I should have reported this earlier, sorry).

I have performed a clean install on a new host, taken Sail into use in my existing environment, and even performed the aforementioned Laravel 8 -> 9 upgrade with a purpose-built Ubuntu 20.04 -> 22.04 virtual machine, but I always get the mysqldump: unknown variable 'column-statistics=0'. I still believe this is a valid issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants