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
"MySQL has gone away" more common with PHP 7.2+ #15451
Comments
@limitstudios It be great if you look into this and find something. Have you tested if there is again a difference for PHP 7.3? Are you maybe planning to give it a try? Maybe PHP 7.2 regressed performance in some particular features. It's possible these performance issues only apply when using specific features/configurations. Some issues might only happen on a specific load etc. While we do support newer PHP versions, it's impossible for us to do advanced performance/load tests for different PHP versions unfortunately. |
Hi @tsteur I would imagine there is, from my testing on a live environment it seems to affect 7.2 and 7.3. I've almost got my profiling working and I'm able to reproduce the performance difference locally so will let you know what I find. |
There is a suspiciously large amount of people reporting something similar to this: Another common thing I see, is that this happens more often on shared hosters, so we can't get more information about the MySQL setup. Some examples:
If someone has a clue on how to reproduce this or what could be causing this change, please comment. |
I can provide a shared hosting environment where this is reproducible if it helps? |
@limitstudios Is your shared hoster by chance in Germany? Maybe it is even the same shared hoster for everyone reporting the issue? |
Nope UK based it could be they all have the same CPanel setup and setting the website version from <7.2 to >=7.2 makes something trigger unexpectedly |
This might be a hint in the right direction: |
Interesting. If this indeed improves it, might be worth switching to nd_mysqli or nd_pdo_mysql fyi @mattab |
This does seem somewhat connected, the options in that forum thread didn't fix it for me; however these steps did
Now when I was getting a lot of the "MySQL has gone away errors" my adapter in config.ini.php was "MYSQLI" when I removed this line, which I think defaults to "PDO_MYSQL" the errors went away under 7.2 and 7.3 (currently on 7.3.17) And I can access the system config status page and the widgets on the dashboard without any "MySQL has gone away" errors, I'll continue to monitor the beginning of this week when the data collection starts to ramp up again. |
For me the nd_mysqli solution seems to work for PHP 7.4.5
I've been fooling around with PHP and PHP-CLI versions to solve an old archiving issue (https://forum.matomo.org/t/mysql-server-has-gone-away/31760/8) that had slipped my mind, but returned after upgrading PHP on several domains. The issue seems to appear exclusively when there are archiving tasks, breaking both core:archive (mysql server has gone away) and the web interface (all websites). I also noticed 2 ways in which the archive task (triggered by cron) fails:
The above seems dependent on which combination of PHP versions I set. I'm using cpanel, where I can set PHP for both domains and CLI. However, I always get one or more Not sure of the above is helpful, but let me know if I can provide you with more information. |
One more user reported back that switching from MySQLi to PDO fixed the issue: |
@Findus23 I wonder if PDO has some sort of connection cleanup/closing where as the MySQLi method doesn't do this in some cases? |
I have this issue, and I can't even install Matomo. I get the error "Error while trying to connect to the database server: SQLSTATE[HY000] [2006] MySQL server has gone away." during the step "3. Database Setup" of the install. Following this article changed nothing. EDIT: I am using the official docker image (the Apache variant), with a MySQL 5 server. I tried MariaDB, MySQL 8 with no success. |
@ThibaultVlacich which php version do you use, can you try to upgrade to PHP 7.4 latest, this might help? |
@mattab I am using the official Docker image, so the version included with it (meaning php 7.4). Just using the official Docker image with no change just doesn't work. So even if the official Docker image doesn't work out-of-the-box, there's a serious issue here. EDIT: just pull the example available in the repo (here), run |
It might help to use eg php nd_mysqli or nd_pdo_mysql #15451 (comment) . Any chance to try that in the one without SSD? |
In my case, this error disappeared after I changed the adapter from MYSQLI to PDO\MYSQL. I am using Matomo 3.14.1 with PHP 7.4.11 and MySQL 8.0.20-11.3. I tried any other things like this: https://matomo.org/faq/troubleshooting/faq_183/ and nothing helped. I had this error very often during cron archive. Right after I changed the type of the adapter the error isn't there anymore. |
Hello and a pleasure to be able to give a little in this great community I was having this problem also.
Then when going to create the database tables, automatically i will get the ip 127.0.0.1 and the error 🙀 Thanks for this great FLOSS software! |
Hi,
I've setup quite a few matomo instances at our hosting company and have noticed that as soon as we upgrade a customers PHP to 7.2 or above, the matomo instance starts showing lots of "MySQL has gone away" errors and performance goes down.
As soon as we downgrade back to 7.1 these errors go away and the system functions and performs fine. With PHP 7.1 being end of life, it would probably be a good idea looking to support the newer versions and ensuring performance is on par or better, and that errors like the above don't appear.
I'm a PHP developer myself so happy to work with you guys and provide a test environment to help debug and fix.
The text was updated successfully, but these errors were encountered: