-
Notifications
You must be signed in to change notification settings - Fork 176
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
Running test with mysql database throws too many connections or memory issue #200
Comments
Disable Pulse in your tests. You can add |
Hello. I've already done that and the problem still persists |
@walterdis can you run the following terminal command in your application and let me know the output.
|
Have you configured a different database connection for Pulse but maybe pointing to the same MySQL server? It's the only reason I can think why Pulse's existence would increase the number of database connections. |
Although I'm not entirely sure the root cause of this issue, I've created a PR that might resolve it by not hitting the ingest unless there are entries to store. |
@timacdonald Hello ;)
@jessarcher Hi, i have configured it to use Redis. I was hoping that when I did this, Laravel Pulse would start getting the data through the worker and not open connections to the database all the time |
@walterdis can you please upgrade to Please ensure that |
@timacdonald Hi, thx for the answer ;) I've tested 2 scenarios:
|
This just happened to us in production... |
@Andilutten were you using Octane? |
@taylorotwell Nope |
@Andilutten could you provide information here on what your setup looks like?
Some other information that would help: |
@walterdis if you disable pulse AND telescope in your test suite by putting the following in your <?xml version="1.0" encoding="UTF-8"?>
<phpunit>
<!-- ... -->
<php>
<!-- ... -->
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="PULSE_ENABLED" value="false"/>
</php>
</phpunit> do you still get the memory / db issues in your tests? Just trying to nail down where things could be falling apart in the tests. |
We have the same issue. Both Telescope and Pulse are disabled in the CI environment:
|
@timacdonald Yes, i've tested all scenarios i could think of. My current phpunit.xml (yes, i've tried without the clockwork extension) <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" backupGlobals="false"
bootstrap="vendor/autoload.php" colors="true" stopOnFailure="true" cacheDirectory=".phpunit.cache" processIsolation="false">
<testsuites>
<testsuite name="Modules">
<directory suffix="Test.php">./app-modules/*/tests/Feature</directory>
<directory suffix="Test.php">./app-modules/*/tests/Unit</directory>
</testsuite>
</testsuites>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
<server name="DB_FOREIGN_KEYS" value="true"/>
<server name="PULSE_ENABLED" value="false"/>
<ini name="error_reporting" value="E_ALL"/>
<ini name="display_errors" value="1"/>
</php>
<extensions>
<bootstrap class="Clockwork\Support\Laravel\Tests\ClockworkExtension"/>
</extensions>
</phpunit> .env.testing CLOCKWORK_ENABLE=false
CLOCKWORK_TESTS_COLLECT=false
PULSE_INGEST_DRIVER=redis
PULSE_REDIS_CONNECTION=pulse
REDIS_PULSE_DB=1
PULSE_ENABLED=false Still getting the memory exception running |
I wasnt using redis ingest. The pulse setup was pretty much straight out of the box. I was using the applications MySQL database, (hence the mentioned outage). I was not running either the check or work command, and the application is only using nightly sync jobs. So no queue workers required. (Atleast not right now) I don't have access to the code right now since I'm out and about , but I will post the version info when I get back home. |
Got some more PRs coming in that should help address the memory issues. Will likely tag them early next week. Still working on understanding the DB connection issues. If there is any additional information you think could be useful to help us replicate the issue, that would be amazing 🤘 |
@timacdonald |
Hi, I have same issue here, tested with v1.0.0-beta5 and v1.0.0-beta7 There are 800 tests in my project, test are running on mysql, phpunit.xml file with PULSE_ENABLED as false. No redis. After 400 tests I get this error: Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 266240 bytes) in .... each time in different file |
I'm experiencing memory issues as well. my db is postgres. I have a command which loops over a dbf file ~70k rows and saves the data in two tables using updateorcreate. when i have pulse enabled the mem required goes from a starting point of ~40mb to 250mb. with pulse diabled mem stays ~ 40mbs through the entire process |
@timacdonald Hi. |
Hey folks, The memory issue should be resolved with a buffer limit introduced in #250 The DB connection issue in testsuites will be resolved using the This means that you can put a cap on the amount of memory Pulse will capture in it's buffer and also keep your tests fast by not requiring Pulse to actually write to the DB during tests - but keep it enabled to reflect production. All ingesting is wrapped in |
@Andilutten do you know what kind of load you application was under around that time? Was it a substantial amount of requests per minute? I'm thinking perhaps you had a lot of traffic and the For high-traffic applications we recommend the Redis driver for this reason. I'm sorry again that this impacted your production app. |
Hello @timacdonald I've done a What i`m doing wrong? Thanks |
@Andilutten we will tag a release next week that should allow you to update. Will keep ya posted. |
|
@timacdonald i ran the monthly upload with the new beta release and it worked great this time. Thank you!! |
It's working here as well. Thanks! ;) |
Great to hear! |
@tasarsu did the beta8 push fix your issue? Having same memory error as you commented. I have more than 800 test cases, it timesout with error:
Laravel pulse version:
phpunit.xml
@timacdonald I don't know if I need to open another issue. |
@taghwo I think I know what could be impacting your testsuite. Could you try something for me to help confirm: would you search of all usages of the You should at least find them in the following files:
Then could you try running the testsuite again and let me know if there is an improvement? That function has a memory leak that is potentially impacting your testsuite. I've submitted fix / work around to the framework (laravel/framework#49557). |
Hi @taghwo and @timacdonald |
Thank you so much for trying that out. We'll merge the framework fix and encourage everyone to update to get the fix across the ecosystem. I'll close this and we can track the framework PR. |
@timacdonald Unfortunately after commenting those lines out I still get the memory issue. Uninstalling Laravel Pulse the test suite runs successfully. |
@taghwo I've found another memory leak that could be casing the issue; this time in Livewire. I've submitted a fix (livewire/livewire#7677). Could you please try commenting out the
and then opening the pulse/src/PulseServiceProvider.php Line 170 in 32fb030
Would love to know if that helps the situation at all. Thank you again for helping out with this one. |
I've also found another memory leak in the framework that could have been impacting you due to the introduction of Livewire. Could you make sure to update to at least |
Will try these out over the weekend and get back on Monday. |
Hello @timacdonald, I have some update. Current package versions: Laravel Pulse
Laravel framework
Current Issue:
If I add —with-dependencies after "update laravel/pulse:1.0.0-beta8" it updates the Laravel/framework to v10.39 plus other dependencies which I am not in control of. |
@taghwo, Pulse now requires a minimum framework version of I recommend updating at least to I'm glad to hear the memory issue was resolved. |
Worked fine now. Thanks @timacdonald. |
I have same issue, it's not resolved or re-apeared again. Memory leaks when running test everything is disabled in phpunit.xml. Pulse version: beta15 |
@RomkaLTU, are you saying you are experiencing memory leaks in your testsuite on those versions? |
Pulse Version
latest
Laravel Version
10.32
PHP Version
8.1.9
Livewire Version
dont know
Database Driver & Version
MySQL 8.0.31 for macOS 14.0 on arm64 (Docker)
Description
Hello,
When I run tests using the MySQL database with --parallel, even with Redis, the tests stop in the middle, giving me the error message: "Too many connections."
If i run without --parallel, it's giving me the memory limit exception
Am I doing something wrong?
Steps To Reproduce
Configure tests to use mysql
The text was updated successfully, but these errors were encountered: