-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Potential infinite recursion when executing schema:dump
#52436
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
Comments
You're on a very old v11 version. Can you try updating all your dependencies with |
Version P.S.: I still ran |
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
Hi, @FeBe95 I followed the steps, try to replicate the issue but was unsuccessful. My database version is MySQL 5.7, and the MySQL user has the following permissions:
When running
It's there anything I missed? |
1. Replication@rust17 I recreated a user with exactly the same grants as yours again (all except
and re-run
Just to make sure, have you set 2. VersionsAlso, I can see that my output looks a bit different from yours. I suppose we are using different MySQL/MariaDB versions?
3. Error TriggerRegardless of that, Basically any error, that is not caught by Laravel beforehand, will do - e.g. an incorrect password is always caught during initial setup of the PDO connection, so this would not trigger the infinite loop.
That's why I came up with removing the |
Yes. The .env file is as bellow:
Double-check each step in case of making any difference. On my machine,
May it's due to the Windows platform? Unfortunately, I don’t have a Windows environment right now, can’t replicate the issue. |
Hm, that's odd... Regardless, the potential infinite recursion should also be noticeable by looking at the code directly, without any execution at all: framework/src/Illuminate/Database/Schema/MySqlSchemaState.php Lines 155 to 159 in e1a9c5d
Let's convert these lines to pseudo code. For context: This code is executed, whenever Pseudo Code:
This code could potentially result in an infinite recursion, whenever the removal of the flag does not fix the actual error. In my forced example the error message contains
but not exactly
Here the actual error does not complain about an unknown flag, but is completely unrelated, while the error output happens to contain the searched string (as a working directory). Same goes for the second check further below: framework/src/Illuminate/Database/Schema/MySqlSchemaState.php Lines 161 to 165 in e1a9c5d
In my case I forced this by naming my directory |
I think I get what you’re saying. Regardless of how the |
Yes! That is exactly what I meant. 😊 Regarding your solution: The working directory is only one possible cause, that I came up with for the sake of this issue. There are other possible causes for an infinite loop besides the working directory though. For example, mentioned here on StackOverflow, one can create a config file for I know, these issues might be somewhat unlikely to happen, but I think having even the sightliest possibility to run in an infinite loop somewhere in the code is "bad design". So excluding the working directory from the error message is a step in the right direction, but I would advocate preventing any infinite loop here, by e.g. introducing a |
Thanks. To make this code more robust, it's better to add some logic to ensure that the recursion has a clear stopping point. I’ll try to submit a pull request for this. |
* feat: Add clear stopping point for recursion * style: fix styleci * Update MySqlSchemaState.php * Update DatabaseMySqlSchemaStateTest.php * Update MySqlSchemaState.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
Thanks @rust17 |
Laravel Version
11.20.0
PHP Version
8.2.12
Database Driver & Version
MariaDB 10.6.16
Description
I noticed that the execution of
can potentially run into two infinite recursive loop here:
framework/src/Illuminate/Database/Schema/MySqlSchemaState.php
Lines 155 to 165 in e1a9c5d
There's even a comment on StackOverflow, where a user ran into exactly this issue:
https://stackoverflow.com/questions/59410746/getting-mysqldump-error-unknown-variable-column-statistics-0-when-exporting#comment136792230_59442494
I am fine with recursion in general, but there needs to be some kind of fail-safe to catch infinit loops here, e.g. a max retry count. We can't rely on consistent output of
mysqldump
here.Steps To Reproduce
TLDR:
composer create-project laravel/laravel column-statistics
DB_USERNAME
to a user that does not have theLOCK TABLES
permissionphp artisan schema:dump
Output:
Detailed Explanation:
There are for sure multiple ways of triggering an infinite recursion here, but the simplest way, that I have found, is to have the word
column-statistics
somewhere in the path of your working directory. Now, if any error is reported bymysqldump
, it will result in an infinite loop, since the working directory is part of the error output that is being parsed here:framework/src/Illuminate/Database/Schema/MySqlSchemaState.php
Line 155 in e1a9c5d
In my case
$e->getMessage()
looked like this:The text was updated successfully, but these errors were encountered: