SQLSTATE [HY000] Too Many Connections

Recently our server started running at max CPU and the Web GUI would become unresponsive with the Error Above. Something is creating hundreds of CDR Select statements. They all have the same linkedid . We are also experiencing issues with Sangoma Connect, but I believe this is a symptom of our SQL connections being maxed out and not part of the issue. We are on FreePBX and here is an example of the MySQL/MariaDB process
| 610 | freepbxuser | localhost | asteriskcdrdb | Query | 28 | Sending data | SELECT * FROM cdr WHERE NOT(recordingfile = β€˜β€™) AND (uniqueid = β€˜1704390148.46851’ OR linkedid = '17 | 0.000 |
| 611 | freepbxuser | localhost | asterisk | Sleep | 28 | | NULL | 0.000 |

I’m just realizing the Query is truncated in the process log and they all just start with 17, these queries appear to be hanging, and therefore they constantly build up, I have yet to determine what is initiating them, any ideas on where to look for troubleshooting would be appreciated, I’m not an expert on this.

While you work on the root cause, increasing you max connections may help mitigate some of the impacts.

mysql> SET GLOBAL max_connections = 5000;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE "max_connections";
| Variable_name   | Value |
| max_connections | 5000  |
1 row in set (0.00 sec)

Seems like there were a couple of issues, most likely caused by an update.
Working with Sangoma support they were able to provide me with a fix to the restapps and cdr modules, was a known issue impacting SQL performance. Don’t know how long this fix will be relevant but here it is.

fwconsole ma downloadinstall restapps --tag
fwconsole ma downloadinstall cdr --tag
fwconsole chown
fwconsole reload

Once this was applied we also notice there was an issue with Zulu causing massive amounts of queries as well, since we had not be utilizing it we shutdown Zulu, with the following commands.

fwconsole stop zulu
fwconsole ma delete zulu
fwconsole reload
fwconsole util clearunuseddevices
fwconsole reload

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.