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

SQLSTATE[08004] [1040] Too many connections in a batch of functional tests #1906

Open
papatti opened this issue Sep 14, 2022 · 0 comments
Open

Comments

@papatti
Copy link

papatti commented Sep 14, 2022

I've upgraded my propel1 to Propel2:beta1 in a working project created with Symfony and PropelBundle (sligthly modified version of Skyfox's PropelBundle). Project woks fine! :)

I also have a ton of unit- and tunctional test, including over 200 api tests. They work perfectly well, when using the ConnectionWrapper class, but fail after the first ~200 tests with SQLSTATE[08004] [1040] Too many connections error message having DebugPDO as class.

This is probably because each api call will trigger a full Symfony boot sequence, including PropelBundle's boot function, which creates a new connection each time, until the limit is reached.
DebugPDO is a ConnectionWrapper with useDebug=true by default. Same result when ConnectionWrapper was used with useDebug=true.

It can be a problem of PHPUnit, PropelBundle, Propel, or my code. But I think it belongs here.

Theoretically the ConnectionManagerSingle should close existing connections when new configuration is provided (ConnectionManagerSingle::setConfiguration()) by detaching connection objects. If nobody uses them, objects are destroyed, connections are closed. But! I think if debug is set to true, then though the objects are detached from ConnectionManagerSingle::connection, they remain connected to something else (a logger?), thus they are considered as "objects in use", objects are not distroyed, connections are not closed, and they just pile up, until it breaks down.

Long story short: Database connections are closed with ConnectionWrapper, but not closed with DebugPDO or ConnectionWrapper with useDebug=true. And if for some reason (200+ api test in batch) many of them are created with the same properties, existing ones are not reused or closed, their number keeps growing. (checked with beta2, same outcome)

Note: in propel1 there was a !\Propel::isInit() function, this was used in PropelBundle to avoid multiple connection instances, but this has been removed, and the Propel::init() is also deprecated.

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

1 participant