Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
1.6k views
in Q2A Core by
Hi, I have been facing terrible issue since I upgraded my database to MYSQL 5.7. Q2A is doing a lot of connections to Database and I'm getting the following message in Apache log:

PHP Warning:  mysqli::__construct(): (HY000/1040): Too many connections in /var/www/html/qa/qa-include/qa-db.php on line 83

For MYSQL I see a lot of threads and most of them sleeping. I do not have persistent connections enabled and have set 30s for timeout. Still what could be the problem ?

 7267 | qauser | localhost:43418 | qa1  | Sleep   |    4 |          | NULL             |
| 7268 | qauser | localhost:43420 | qa1  | Sleep   |    4 |          | NULL             |
| 7269 | qauser | localhost:43426 | qa1  | Sleep   |    4 |          | NULL             |
| 7270 | qauser | localhost:43428 | qa1  | Sleep   |    4 |          | NULL             |
| 7271 | qauser | localhost:43432 | qa1  | Sleep   |    4 |          | NULL             |
| 7273 | qauser | localhost:43440 | qa1  | Sleep   |    4 |          | NULL             |
| 7275 | qauser | localhost:43448 | qa1  | Sleep   |    4 |          | NULL             |
| 7277 | qauser | localhost:43458 | qa1  | Sleep   |    4 |          | NULL             |
| 7280 | qauser | localhost:43464 | qa1  | Sleep   |    4 |          | NULL             |
| 7281 | qauser | localhost:43470 | qa1  | Sleep   |    4 |          | NULL
Q2A version: 1.7.4
by
Seems to be caused by Q2a-share plugin. But the issue is not there on another Q2A running on same server.
by
Hi Arjunsuresh.
Removing the plugin solved the problem?
Or did you need to make any changes to the database?
by
Just removed the plugin. I later on found the problem to be an image create function in the plugin causing a memory leak but couldn't really fix it.
by
Thanks, Arjunsuresh!
by
@arjunsuresh, who is author of Q2a-share plugin. let us report to him for fixing this issue.
by
It is Ami. But the issue is due to imagecreate call if I remember correctly.
by
Thanks! please post issue on github, he may fix.
https://github.com/amiyasahu/q2a-social-share/issues
by
I just glanced at the plugin's code and couldn't find any database query.  I don't think it would generate additional database connections. Maybe there was a peek on the users, exceeded your connection and just circumstantially they dropped when you removed the plugin. I would retest this.

In Github's issue #17 you mention a memory leak. That has nothing to do with the issue in this question. You also mentioned server crashes and you haven't provided any log about the crash. That would considerably help to identify the issue.
by
Thank you pupi. I suppose the memory leak caused mysql to ran out of memory and subsequently the DB connections started failing. There was nothing interesting in the log -- I'll re-test it if possible.
by
Did you confirm MySQL settings below?
1. max_connections (Normally, default is 151)
2. max_user_connections (Normally, default is 0 [unlimited])

Investigation query for phpMyAdmin:
SHOW GLOBAL VARIABLES like 'max_%connections';
by
Yes, I believe I tried many settings -- this happened about a year ago and only option was to remove the plugin. I later on added the plugin back and commented out the problem part -- which was creating an image.

Please log in or register to answer this question.

...