Parsing of multiple pages in Latte 3.0 causes the PHP and Apache stuck until restart of the Apache

TomasA
Member | 11
+
0
-

Hello,
when I request multiple pages for the first time (in multiple tabs in Chrome) simultaneously (starting the one request before the previous one ends), then some of these processes often end in some kind of infinite loop. These requests never end; they remain in PHP and Apache and keep using my CPU. The only way to end them is to kill the Apache. With just a few attempts, I was even able to make Apache and PHP stuck entirely, causing 100 % usage of my CPU.

I believe there might be a problem with the coroutines in simultaneous parsing of pages. I guess the first call works with the coroutines in a manner that makes them unavailable for the second call. This wouldn't be such a big problem if the second call ended with some error or timeout. However, in this way, the second call allocates its resources and the computational time of the CPU indefinitely.

I am developing on the following setup:
Windows 10
Wampserver 3.3.2 – 64bit
Apache 2.4.58
PHP 8.3.0

I am quite interested if this behaviour also occurs with PHP-FPM. It would be very unfortunate if one PHP application would be able to break the PHP-FPM process for all PHP applications on the same server. I would see that as a serious threat.

Last edited by TomasA (2024-04-03 01:32)

Marek Bartoš
Nette Blogger | 1261
+
0
-

Have you tried deleting the temp folder or setting max_execution_time? Maybe it's just the lock that is created during compilation that is not properly released, making the other requests waiting for that lock to wait.

TomasA
Member | 11
+
0
-

I have tried both. I have lowered the temp folder, lowered the max_execution_time from “120” to “30” and restarted Apache. Still, if I try fast enough, I am able to break it again.

Marek Bartoš
Nette Blogger | 1261
+
0
-

I know you will break it, but that's not the point. I am trying to identify the problem.

If the lock is not properly released, then deleting temp folder (and therefore the lock file) should let the next process try compile the files. Once you delete lock files, another process should finish. If you delete lock files for every process that got stuck, they should all finish and you shouldn't need to restart Apache. You may need to do it repeatedly, only one process at a time creates the lock.

If it's the problem, then it should be fairly easy to fix the problem in Latte by releasing the lock.

TomasA
Member | 11
+
0
-

I have started with an empty temp folder, Apache using 0% CPU. Started about 10 requests, 5 of them stuck, Apache using 68% CPU. Then, I have tried to delete the temp folder again (to release the lock). Nothing changes, 5 requests still stuck, Apache still using 68% CPU.

Last edited by TomasA (2024-04-03 02:36)

Lumeriol
Generous Backer | 63
+
+1
-

Try temporarily disabling xDebug in WAMP, as its version 3.3.1 does not work properly with PHP 8.3.x (maybe on Windows only).

There was a similar problem just after the release of PHP 8.1 and it was only solved by the new version of xDebug.

Comment out the zend_extension=… line in php.ini and phpForApache.ini (put a semicolon before it) and add to the new line xdebug.mode=off (you might have xdebug.mode=develop, so replace “develop” with “off”)

After restart of Apache, CPU load should be on normal state.

TomasA
Member | 11
+
+2
-

You're right. Disabling of xdebug.mode works like a charm.

It was even the reason of significantly slower processing of all pages, even already parsed ones.

Lumeriol
Generous Backer | 63
+
+1
-

TomasA wrote:

You're right. Disabling of xdebug.mode works like a charm.

It was even the reason of significantly slower processing of all pages, even already parsed ones.

Xdebug has been updated and the problem has been fixed.