After years of flawless operation, my Matomo installation has started to behave erratically, producing the error SQLSTATE[HY000] [2002] No such file or directory
every few minutes or even seconds.
Curiously, the log in ./tmp/logs/matomo
is empty.
However I did retrieve the following from my Apache error logs (with IP and directory names redacted here):
[Mon Feb 03 05:28:10.062739 2020] [php7:error] [pid 6870] [client XX.XXX.XXX.XX1:56145] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /var/www/html/matomo.domain.ltd/libs/Zend/Db/Statement/Pdo.php:228\nStack trace:\n#0 /var/www/html/matomo.domain.ltd/libs/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)\n#1 /var/www/html/matomo.domain.ltd/libs/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)\n#2 /var/www/html/matomo.domain.ltd/libs/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)\n#3 /var/www/html/matomo.domain.ltd/libs/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO piw...', Array)\n#4 /var/www/html/matomo.domain.ltd/core/Db/Adapter/Pdo/Mysql.php(309): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO piw...', Array)\n#5 /var/www/html/matomo.domain.ltd/core/Session/SaveHandler/DbTable.php(113): Piwik\\Db\\Adapter\\Pdo\\Mysql->query('INSERT INTO piw...', Array)\n#6 /var/www/html/matomo.domain.ltd/core/Session/SaveHandler/DbTable.php(145): Piwik\\Session\\SaveHandler\\DbTable->query('INSERT INTO piw...', Array)\n#7 [internal function]: Piwi in /var/www/html/matomo.domain.ltd/libs/Zend/Db/Statement/Pdo.php on line 234, referer: https://matomo.domain.ltd/index.php?module=CoreHome&action=index&idSite=1&period=range&date=last7&activated=&updated=5
[Mon Feb 03 05:28:12.366756 2020] [php7:notice] [pid 12862] [client XX.XXX.XXX.XX1:56150] Error in Matomo: Cannot connect to the database: SQLSTATE[HY000] [2002] No such file or directory This may be a temporary issue, try refreshing the page. If the problem persists please contact your Matomo administrator.
[Mon Feb 03 05:30:12.008210 2020] [php7:notice] [pid 4627] [client XX.XXX.XXX.XX1:56207] Error in Matomo: Cannot connect to the database: SQLSTATE[HY000] [2002] No such file or directory This may be a temporary issue, try refreshing the page. If the problem persists please contact your Matomo administrator., referer: https://matomo.domain.ltd/index.php?module=Installation&action=systemCheckPage&idSite=1&period=range&date=last7&showtitle=1&random=4058
[Mon Feb 03 06:34:09.538056 2020] [php7:notice] [pid 30266] [client XX.XXX.XXX.XX1:56889] Error in Matomo: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away, referer: https://matomo.domain.ltd/index.php?module=CoreHome&action=index&idSite=1&period=range&date=last7
When the error started creeping in, I took the initiative to manual empty all statistics, visit logs, and events SQL database. I followed the following instructions:
https://matomo.org/docs/managing-your-databases-size/
https://matomo.org/faq/how-to/faq_73/
Thank you in advance for any help.