<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">Hi,<br />
<br />
I came across a strange problem: in some php versions you may have persistent mysql connection, needless to say this is a pain in the back, since by default mysql will kill idle/sleepy connections after 28800 seconds (roughly 8 hours), and if unluckily it reaches 131 child process or around 100 process from mysql shell, it’ll freeze giving a blank white page until one of the following:<br />
a. Some of the process are killed automatically because timeout limit is reached or manually<br />
b. Complete reset of mysql service (systemctl restart/relaod mysql)<br />
<br />
The fix is in php.ini:<br />
Set mysqli.allow_persistent to Off and mysqli.max_persistent to 0. In some versions you’ll find their values respectively On and -1 which is limitless.<br />
<br />
After I set these new values, there were no sleepy process since mysql was killing them as soon as php-fpm ended.<br />
<br />
Final considerations:<br />
Why is the library AdoDB not closing the db pool explicitly? Relying on PHP is way too risky: prior to the solution in the best case scenario there were a couple of process brought up in mysql, in the worst case the were ten and refreshing 5 times the dashboard with some widget was enough to paralyse the system.<br />
<br />
You can check yourself by logging in to your mysql shell and giving this command:<br />
show processlist;<br />
<br />
Or from your shell (linux) give the pstree command and look at mysql and how many process it has spawned. On my system with 131 process it hanged (24gb ram).<br />
<br />
More at <a href="https://www.php.net/manual/en/mysqli.configuration.php#ini.mysqli.allow-persisten%20t" target="_blank">https://www.php.net/manual/en/mysqli.configuration.php#ini.mysqli.allow-persisten t</a><br />
<br /></div>
</div>
<div name="messageSignatureSection"><br />
<div class="matchFont"><font color="#C6C6C6"><b><span style="">Sukhdev Mohan</span></b></font><span style=""></span><br />
<font color="#999999"><b><span style="">Developer</span></b></font><br /></div>
</div>
</body>
</html>