-
Notifications
You must be signed in to change notification settings - Fork 47
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
Allowed memory size exhausted during dump #57
Comments
I'll try to clone the repo and debug into the TableDependencyResolver. It seems to me there might be an cyclic dependencies. |
When I remove
I am getting the following error:
When removing
as well it works just fine. I am a bit confused in how I can figure out what the problem is with those tables. |
Debugging this together with Daniel... It is possible with
to find out the forein keys. But adding all the tables returned here (and the same for |
The problem is in this recursive function. If we add
to
the resolver seems to finish but another problem appears. Current assumption is that it is not detecting cyclic dependencies which are like A -> B -> A but only A -> A. Because we have
and also
@guvra Question: What is the purpose of the foreign key resolving? If we just do nothing in the fuction ( We created text file of the foreign-key-relations for the graphviz tool and ran the nodes echod in that function through |
When trying to avoid adding a dependency that has been already resolve like this:
We're getting the following error:
|
Hi, When gdpr-dump removes rows ( Table dependencies are resolved in the class TableDependencyResolver. Cyclic dependencies are detected to avoid infinite loops. The situation where two tables depend on each other is not currently detected by the dependency resolver. So to solve this problem, you need to either update the table dependency resolver, or disable the table filter extension (there's not config for that yet, it has to be done manually in the code). The cardinality violation error seems to be a different issue though. |
@guvra Thanks for the explenation, that seems like a pretty cool feature. We think we fixed the first issue with |
I've pushed a WIP commit. I did not look into the followup issue mentioned in #57 (comment). |
Is due to a cyclic dependency within \Smile\GdprDump\Dumper\Mysqldump\TableFilterExtension::addDependentFilter |
In the case of the cycle If I change the condition to
|
It seems there's a mismatch between You could easily check this by adding var_dumps in the addDependentFilter function (or using xdebug). |
I couldn't find any mismatch but I found cases with two foreign keys between two tables like this:
I think there are in total 3 issues here:
SELECT (`id`) FROM `products`; #works
SELECT (`id`, `name`) FROM `products`; #error @guvra I will provide a PR with solutions for all 3 cases. The first case should be clear with the test but as I said I did not manage to create a failing test (I tried to create two tables that reference each other like A -> B, B -> A) maybe you have an idea? For the third case I do not have time to create a test right now but it should be fairly straight forward. I think you know the code the best and might have an idea whether our solutions make sense or are completely off. |
Just to make sure I understood your problems, could you test if the commit I just added fixes all your issues? |
@guvra I can dump without any error on the branch fix-multi-column-fk and I compared a dump from your branch with #58 and they are identical: $ diff our_master.sql master.sql
6c6
< -- Date: Fri, 05 Nov 2021 09:13:39 +0100
---
> -- Date: Fri, 05 Nov 2021 09:14:45 +0100
8858c8858
< -- Dump completed on: Fri, 05 Nov 2021 09:13:39 +0100
---
> -- Dump completed on: Fri, 05 Nov 2021 09:14:45 +0100
I wondered if changing |
@DanieliMi OK thanks for testing, so this commit solves all the issues you had? If that's the case I can add a few functional tests and create a new release that includes this commit. |
Yes it does.
That would be amazing. |
@DanieliMi I'm reopening this, after adding more functional tests, I realized there is a regression if I replace |
It seems that Changing the condition to |
Fixed in commit 0291602 on master branch @DanieliMi could you test this fix? |
Hi @guvra I tested your commit and I did not run into any issues. The issues are solved. Thank you very much for your effort! |
@DanieliMi OK thanks, I've released version 2.2.1 👍 Hopefully it will be easier to fix this kind of error in the future, there are a lot more unit/functional tests, and the complex functions are now documented (in the PHPDoc of the function, e.g. getDependencies in TableDependencyResolver). |
Preconditions
GdprDump Version: 2.2.0
PHP Version: 7.4.25
Database Version: 10.3.31-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Steps to reproduce
gdpr-dump.yml
gdpr-dump gdpr-dump.yaml | sed 's$VALUES ($VALUES\n($g' | sed 's$),($),\n($g' > sql/master.sql
Expected result
A dump is created.
Actual result
PHP Fatal error
The text was updated successfully, but these errors were encountered: