symfony: symfony/console 5.4.12 make db Too many connection errors

Symfony version(s) affected

5.4.12

Description

I upgrade symfony/console to last version (5.4.12) and lots of my functionnal tests doesn’t work anymore because of error like:

1) App\Tests\Infra\Review\ReviewBoosterSenderTest::****Send with data set "sms" (1, 2)
Doctrine\DBAL\Exception\DriverException: An exception occurred in the driver: SQLSTATE[08004] [1040] Too many connections

/root/project/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:117
/root/project/vendor/doctrine/dbal/src/Connection.php:1818
/root/project/vendor/doctrine/dbal/src/Connection.php:1767
/root/project/vendor/doctrine/dbal/src/Connection.php:328
/root/project/vendor/doctrine/dbal/src/Connection.php:1529
/root/project/vendor/doctrine/dbal/src/Connection.php:1010
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:750
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:768
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:521
/root/project/var/cache/****/ContainerRdlthlA/EntityManager_9a5be93.php:95
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:199
/root/project/src/Infra/Shop/Repository/ShopRepository.php:42
/root/project/src/Infra/Review/ReviewBoosterSender.php:47
/root/project/****s/Infra/Review/ReviewBoosterSenderTest.php:27
/root/project/vendor/phpunit/phpunit/src/Framework/TestResult.php:726
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:673

Caused by
Doctrine\DBAL\Driver\PDO\Exception: SQLSTATE[08004] [1040] Too many connections

/root/project/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28
/root/project/vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php:34
/root/project/vendor/doctrine/dbal/src/Connection.php:326
/root/project/vendor/doctrine/dbal/src/Connection.php:1529
/root/project/vendor/doctrine/dbal/src/Connection.php:1010
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:750
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:768
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:521
/root/project/var/cache/****/ContainerRdlthlA/EntityManager_9a5be93.php:95
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:199
/root/project/src/Infra/Shop/Repository/ShopRepository.php:42
/root/project/src/Infra/Review/ReviewBoosterSender.php:47
/root/project/****s/Infra/Review/ReviewBoosterSenderTest.php:27
/root/project/vendor/phpunit/phpunit/src/Framework/TestResult.php:726
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:673

Caused by
PDOException: SQLSTATE[08004] [1040] Too many connections

/root/project/vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php:28
/root/project/vendor/doctrine/dbal/src/Connection.php:326
/root/project/vendor/doctrine/dbal/src/Connection.php:1529
/root/project/vendor/doctrine/dbal/src/Connection.php:1010
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:750
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:768
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:521
/root/project/var/cache/****/ContainerRdlthlA/EntityManager_9a5be93.php:95
/root/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:199
/root/project/src/Infra/Shop/Repository/ShopRepository.php:42
/root/project/src/Infra/Review/ReviewBoosterSender.php:47
/root/project/****s/Infra/Review/ReviewBoosterSenderTest.php:27
/root/project/vendor/phpunit/phpunit/src/Framework/TestResult.php:726
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
/root/project/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:673

Really wird problem but I don’t have it with symfony/console 5.4.11. Is it possible there is a problem in https://github.com/symfony/console/compare/v5.4.11...v5.4.12 ?

How to reproduce

Run lot of functionnals tests on a project with symfony/console 5.4.12 installed

Possible Solution

No response

Additional Context

It is not happened when only one tests is run.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

@kfrohwein To be clear from your comments, both v5.4.10 and v5.4.11, of the Console Component, do not exhibit the defect, yet you DO definitively and repeatedly experience the defect in v5.4.12 – full stop? Second question, have you tried any patches beyond v5.4.12 (specifically, v5.4.[13-24])? Let us know! Super useful!

@Kleinast You experienced the defect at patch v5.4.12? Specifically and unequivocally that patch? If yes, that corroborates @kfrohwein report “to the tea”. I know a project that is running v5.4.24 and is experiencing the “Too many connections” error. So potentially three affected people/orgs here that took time to document here… one can only imagine how many more are out there struggling with this seemingly phantomish edge/corner case!

Genesis:

Breaking Change (Per Anecdotal Reports / Not Confirmed):

Authors are @xabbuh and @GwendolenLynch. Change was committed by @nicolas-grekas. Any keen insight(s), ponderings, brain dumps, from anyone in that trio? 🥺

@kfrohwein @Kleinast It was emphasized to you by @xabbuh above, and I’ll re-emphasis what I believe the sentiment in the communication to be:

This issue is will not resolved as-is. We need more contextual information – even just a little, to bring us closer to solving this! Anything is better than nothing and super appreciated! If you don’t have time, etc., to create a failing use case, as was requested above by @xabbuh, could you maybe add some “low hanging fruit” (high value, low effort, info) into this issue? Examples:

  1. Stacktrace(s)?
  2. Database config(s), or simply vendor and version even (are you both running Maria, for example?) Or is someone also running MySQL? What version? Doctrine config (bin/console debug:config ...)?
  3. PHP Version?
  4. Server Information (if linux, something like neofetch --stdout would be great to see).
  5. Is the error ALWAYS "Too many connections …" (fundamentally stemming from surpassing that corresponding configuration option inside of MariaDB and MySQL)?
  6. Active PHP Modules (php -m) on your system? php -i would be great, too. To boot, phpinfo() from the web too 🏆
  7. PHP Context: Does the error occur running via CLI only, via HTTP/Web only, or in both contexts?
  8. Long(er)-Running Process(es): Do you only ever experience the error after PHP runs “for a while”?
  9. Messenger Component: Are you running this component and do you experience this error within the messenger workflow? I am interested in exploring the angle of running bin/console messenger:consume “for a long time”, both as to gather more anecdotal information as well as an easy path to reproducing the issue.
    9a. How are you running your worker/consumer process(es)? More specifically, what command options and/or arguments are you using (time limit and/or max memory and/or etc., …)? If you have the exact command, that’d be epic! Are you leveraging a process manager (i.e., supervisord), or is execution occurring without that added layer – for example, as a Docker Container (Service)? Please let us know! … And if the former, what’s your manager (i.e. supervisor) config? If the latter, may we kindly see your docker compose config construct for your worker definition(s)? Something as simple as docker compose config | yq would be grand!

Thanks ya’ll! 🥇

P.S. @weaverryan big fan of SymfonyCasts bro, have you heard (whispers?) of this issue at all???