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
Archive Cron - MySQL server has gone away #13717
Comments
We have various locks to not archive the same site while another is in progress. This lock may not always work so we have another lock to not start archiving the same period/segment again while another archive is in progress (since Matomo 3.5 or so). I don't know whether we have an Optimize Table lock but this could be actually quite helpful to prevent issues like this 👍 |
A workaround be to disable optimize table in Matomo by setting |
Hey @tsteur, Will disable optimize as advised by you and do it manually once a month - should be plenty enogh as you say! ;-) Thank you, bye from sunny Austria ps) I'm a bit puzzled that both OPTIMIZE Queries are running the exact same amount of time - it seems 1 Job triggered them both the same time?!? (got definitely only 1 archive cron on server) |
BTW: If the "has gone away" error persists check out #13685 (comment) and https://matomo.org/faq/troubleshooting/faq_183/ |
sorry for not getting back on this ... disabling OPTIMIZE immediately helped on my issue - everything working as expected again! ;-) thx, bye from Austria |
@futureweb I'll reopen the issue as we need to ideally add a lock there to not run this twice at the same time. |
As I wrote on the FAQ/feedback page: We need to fix Matomo1 so that it sets the wait_timeout per connection. Setting the server variable is an ugly ugly hack that does not 'play well with others'. Moving from mysqli to pdo/mysql makes it even worse, since old mysqi at least allowed auto-reconnection. (Forums tell me, however, this feature has been deprecated). Further, the pdo-mysql driver does not allow (or is not documented to allow) config/connection parameters to be set via the DSN. Perhaps it is allowed, but it is not documented. The solution can be found here: https://stackoverflow.com/a/21403360/3849157 . The wait_timeout setting should either be as given above (28800) or better yet, configurizable in config.ini. |
@otheus matomo/core/Tracker/Db/Pdo/Mysql.php Line 109 in 77f607d
and report back if it changes anything. If it fixes the issue for you, it would be great if you could create a PR for this. |
Thanks for contributing to this issue. As it has been a few months since the last activity and we believe this is likely not an issue anymore, we will now close this. If that's not the case, please do feel free to either reopen this issue or open a new one. We will gladly take a look again! |
Hey there,
since a few weeks (not 100% sure if it started when we updated to 3.6.1 but it seems like?!) my "core:archive" Cronjob is giving me a nightly" [Zend_Db_Statement_Mysqli_Exception] Mysqli prepare error: MySQL server has gone away" ...
From what I saw - it seems like sometimes the Cron is running into another long running "core:archive" Job which is causing troubles.
When this happens I see 2 long running SQL Threads doing:
OPTIMIZE TABLE piwik_archive_numeric_2012_01,piwik_archive_numeric_2012_02,piwik_archive_num...
Both waiting for "getting table lock" ... guess they stand out against each other ...
For now I try to extend Cron Times to 1.5 Hours and see if it helps ...
But woud it be possible to implement an "Archive Job already running" LOCK or something like that? Guess this should also help with such problems?
thx, bye from Austria
Andreas Schnederle-Wagner
The text was updated successfully, but these errors were encountered: