-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Coroutines are leaking #5618
Comments
I will take a look later. |
Any update? We also want to know if the Coroutine Container, that a Actually, we expect that multiple executions of the callback function of the Your prompt response is awaited. |
You need to show me your timer code. This looks like the coroutines generated after your timer times out are not exiting after communicating with the third-party API, leading to an increasing number of coroutines and exceeding the limit. |
Since there is currently only one tester conducting the tests, it is unlikely to be a user-induced issue, so the timer code needs to be checked. |
As long as the coroutine created by the Timer::tick() callback function exits in a timely manner after completing its task, it will not accumulate. Additionally, there is only one coroutine container in the entire program. |
I wanted to share some details regarding our use of Swoole Timers in custom processes. Instead of using We’ve devised a technique to reload the code within custom process callbacks because Swoole, by default, does not support reloading the code of custom processes—it only reloads worker processes. Additionally, we’ve implemented a hot-reload feature using Here’s the technique we have devised for reloading custom processes:
This technique works well for our hot-reload feature. This is important as we are getting the error of coroutines overflow on the line-number in which we start our custom processes inside MainProcess callback using For your reference, I’m sharing the code for the Timers below to provide a clearer picture of how they’re integrated.
I am attaching the code file if you want to trace these functions further more: |
Issue:
On our live production server, the Max Coroutine limit of 6,000 reached (within one day only), after which we increased the limit to 60,000 and still it reached after two days despite the fact that we are in pilot phase where only one tester is testing the swoole based websocket (broadcasting) server.
Looks like Coroutines are leaking
1. What did you do? If possible, provide a simple script for reproducing the error.
True
go()
to interact asynchronously with external sources like database and third-party APIs.Http\Coroutine\Client
SIGCHLD
andProcess::wait()
as below, assuming it will also clear the Timers, Event Loop and Coroutines created inside child processes.And in the
onBeforeReload()
Event, we passSIGTERM
to the child processes of MCP, and MCP as below:Here is our Repo
2. What did you expect to see?
No Server crash due to Max Coroutine limit exceed with almost no traffic in our production.
3. What did you see instead?
PHP Warning: Swoole\Process::start(): exceed max number of coroutine 60000 in .../swoole-serv/app/Core/Processes/MainProcess.php on line 104 PHP Warning: Swoole\Process::start(): Swoole\Timer->onTimeout handler error in .../swoole-serv/app/Core/Processes/MainProcess.php on line 104
Where
MainProcess.php
file contains code for creating the child processes of MCP4. What version of Swoole are you using (show your
php --ri swoole
)?5. What is your machine environment used (show your
uname -a
&php -v
&gcc -v
) ?uname -a
php -v
gcc -v
The text was updated successfully, but these errors were encountered: