0

Currently helping out on a family run craft commerce site after agency was not very helpful. We are having issues with downtime and I can see a LOT of errors in phperrors.log

This is an example of a common one. I was hoping someone might be able to point me in the right direction on where to dig into the issue. The server is showing no resource issues.

Any help would be much appreciated!

[19-Jul-2022 19:16:57 Europe/Dublin] An Error occurred while handling another error:
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /home/site/craft/vendor/yiisoft/yii2/db/Command.php:1299
Stack trace:
#0 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(1299): PDOStatement->execute()
#1 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(1165): yii\db\Command->internalExecute('SELECT COUNT(*)...')
#2 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(433): yii\db\Command->queryInternal('fetchColumn', 0)
#3 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(496): yii\db\Command->queryScalar()
#4 /home/site/craft/vendor/craftcms/cms/src/db/Query.php(259): yii\db\Query->queryScalar('COUNT(*)', NULL)
#5 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(368): craft\db\Query->queryScalar('COUNT(*)', NULL)
#6 /home/site/craft/vendor/craftcms/cms/src/base/ApplicationTrait.php(375): yii\db\Query->count()
#7 /home/site/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1403): craft\web\Application->getIsMultiSite(false, true)
#8 /home/site/craft/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#9 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\elements\db\GlobalSetQuery))
#10 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query->createCommand(Object(craft\db\Connection))
#11 /home/site/craft/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#12 /home/site/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1547): craft\db\Query->all(NULL)
#13 /home/site/craft/vendor/craftcms/cms/src/services/Globals.php(542): craft\elements\db\ElementQuery->all()
#14 /home/site/craft/vendor/craftcms/cms/src/services/Globals.php(128): craft\services\Globals->_allSets(1)
#15 /home/site/craft/vendor/craftcms/cms/src/web/twig/Extension.php(1468): craft\services\Globals->getAllSets()
#16 /home/site/craft/vendor/twig/twig/src/ExtensionSet.php(329): craft\web\twig\Extension->getGlobals()
#17 /home/site/craft/vendor/twig/twig/src/Environment.php(928): Twig\ExtensionSet->getGlobals()
#18 /home/site/craft/vendor/twig/twig/src/Environment.php(948): Twig\Environment->getGlobals()
#19 /home/site/craft/vendor/twig/twig/src/Template.php(378): Twig\Environment->mergeGlobals(Array)
#20 /home/site/craft/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#21 /home/site/craft/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#22 /home/site/craft/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#23 /home/site/craft/vendor/craftcms/cms/src/web/View.php(390): Twig\Environment->render('_errors/error', Array)
#24 /home/site/craft/vendor/craftcms/cms/src/web/View.php(451): craft\web\View->renderTemplate('_errors/error', Array)
#25 /home/site/craft/vendor/craftcms/cms/src/web/Controller.php(257): craft\web\View->renderPageTemplate('_errors/error', Array, 'site')
#26 /home/site/craft/vendor/craftcms/cms/src/controllers/TemplatesController.php(231): craft\web\Controller->renderTemplate('_errors/error', Array)
#27 [internal function]: craft\controllers\TemplatesController->actionRenderError()
#28 /home/site/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#29 /home/site/craft/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#30 /home/site/craft/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('render-error', Array)
#31 /home/site/craft/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('render-error', Array)
#32 /home/site/craft/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('templates/rende...', Array)
#33 /home/site/craft/vendor/yiisoft/yii2/web/ErrorHandler.php(109): craft\web\Application->runAction('templates/rende...')
#34 /home/site/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(148): yii\web\ErrorHandler->renderException(Object(yii\db\Exception))
#35 /home/site/craft/vendor/yiisoft/yii2/base/ErrorHandler.php(135): craft\web\ErrorHandler->renderException(Object(yii\db\Exception))
#36 /home/site/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(64): yii\base\ErrorHandler->handleException(Object(yii\db\Exception))
#37 [internal function]: craft\web\ErrorHandler->handleException(Object(yii\db\Exception))
#38 {main}

Next yii\db\Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
The SQL being executed was: SELECT COUNT(*)
FROM (SELECT 1
FROM `sites`
LIMIT 2) `x` in /home/site/craft/vendor/yiisoft/yii2/db/Schema.php:678
Stack trace:
#0 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(1304): yii\db\Schema->convertException(Object(PDOException), 'SELECT COUNT(*)...')
#1 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(1165): yii\db\Command->internalExecute('SELECT COUNT(*)...')
#2 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(433): yii\db\Command->queryInternal('fetchColumn', 0)
#3 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(496): yii\db\Command->queryScalar()
#4 /home/site/craft/vendor/craftcms/cms/src/db/Query.php(259): yii\db\Query->queryScalar('COUNT(*)', NULL)
#5 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(368): craft\db\Query->queryScalar('COUNT(*)', NULL)
#6 /home/site/craft/vendor/craftcms/cms/src/base/ApplicationTrait.php(375): yii\db\Query->count()
#7 /home/site/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1403): craft\web\Application->getIsMultiSite(false, true)
#8 /home/site/craft/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#9 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\elements\db\GlobalSetQuery))
#10 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query->createCommand(Object(craft\db\Connection))
#11 /home/site/craft/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#12 /home/site/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1547): craft\db\Query->all(NULL)
#13 /home/site/craft/vendor/craftcms/cms/src/services/Globals.php(542): craft\elements\db\ElementQuery->all()
#14 /home/site/craft/vendor/craftcms/cms/src/services/Globals.php(128): craft\services\Globals->_allSets(1)
#15 /home/site/craft/vendor/craftcms/cms/src/web/twig/Extension.php(1468): craft\services\Globals->getAllSets()
#16 /home/site/craft/vendor/twig/twig/src/ExtensionSet.php(329): craft\web\twig\Extension->getGlobals()
#17 /home/site/craft/vendor/twig/twig/src/Environment.php(928): Twig\ExtensionSet->getGlobals()
#18 /home/site/craft/vendor/twig/twig/src/Environment.php(948): Twig\Environment->getGlobals()
#19 /home/site/craft/vendor/twig/twig/src/Template.php(378): Twig\Environment->mergeGlobals(Array)
#20 /home/site/craft/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#21 /home/site/craft/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#22 /home/site/craft/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#23 /home/site/craft/vendor/craftcms/cms/src/web/View.php(390): Twig\Environment->render('_errors/error', Array)
#24 /home/site/craft/vendor/craftcms/cms/src/web/View.php(451): craft\web\View->renderTemplate('_errors/error', Array)
#25 /home/site/craft/vendor/craftcms/cms/src/web/Controller.php(257): craft\web\View->renderPageTemplate('_errors/error', Array, 'site')
#26 /home/site/craft/vendor/craftcms/cms/src/controllers/TemplatesController.php(231): craft\web\Controller->renderTemplate('_errors/error', Array)
#27 [internal function]: craft\controllers\TemplatesController->actionRenderError()
#28 /home/site/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#29 /home/site/craft/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#30 /home/site/craft/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('render-error', Array)
#31 /home/site/craft/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('render-error', Array)
#32 /home/site/craft/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('templates/rende...', Array)
#33 /home/site/craft/vendor/yiisoft/yii2/web/ErrorHandler.php(109): craft\web\Application->runAction('templates/rende...')
#34 /home/site/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(148): yii\web\ErrorHandler->renderException(Object(yii\db\Exception))
#35 /home/site/craft/vendor/yiisoft/yii2/base/ErrorHandler.php(135): craft\web\ErrorHandler->renderException(Object(yii\db\Exception))
#36 /home/site/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(64): yii\base\ErrorHandler->handleException(Object(yii\db\Exception))
#37 [internal function]: craft\web\ErrorHandler->handleException(Object(yii\db\Exception))
#38 {main}
Additional Information:
Array
(
    [0] => HY000
    [1] => 2006
    [2] => MySQL server has gone away
)

Previous exception:
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /home/site/craft/vendor/yiisoft/yii2/db/Command.php:1299
Stack trace:
#0 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(1299): PDOStatement->execute()
#1 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(1165): yii\db\Command->internalExecute('SELECT COUNT(*)...')
#2 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(433): yii\db\Command->queryInternal('fetchColumn', 0)
#3 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(496): yii\db\Command->queryScalar()
#4 /home/site/craft/vendor/craftcms/cms/src/db/Query.php(259): yii\db\Query->queryScalar('COUNT(*)', NULL)
#5 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(368): craft\db\Query->queryScalar('COUNT(*)', NULL)
#6 /home/site/craft/vendor/craftcms/cms/src/base/ApplicationTrait.php(375): yii\db\Query->count()
#7 /home/site/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1403): craft\web\Application->getIsMultiSite(false, true)
#8 /home/site/craft/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#9 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\elements\db\GlobalSetQuery))
#10 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query->createCommand(Object(craft\db\Connection))
#11 /home/site/craft/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#12 /home/site/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1547): craft\db\Query->all(NULL)
#13 /home/site/craft/vendor/craftcms/cms/src/services/Globals.php(542): craft\elements\db\ElementQuery->all()
#14 /home/site/craft/vendor/craftcms/cms/src/services/Globals.php(128): craft\services\Globals->_allSets(1)
#15 /home/site/craft/vendor/craftcms/cms/src/web/twig/Extension.php(1468): craft\services\Globals->getAllSets()
#16 /home/site/craft/vendor/twig/twig/src/ExtensionSet.php(329): craft\web\twig\Extension->getGlobals()
#17 /home/site/craft/vendor/twig/twig/src/Environment.php(928): Twig\ExtensionSet->getGlobals()
#18 /home/site/craft/vendor/twig/twig/src/Environment.php(948): Twig\Environment->getGlobals()
#19 /home/site/craft/vendor/twig/twig/src/Template.php(378): Twig\Environment->mergeGlobals(Array)
#20 /home/site/craft/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#21 /home/site/craft/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#22 /home/site/craft/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#23 /home/site/craft/vendor/craftcms/cms/src/web/View.php(390): Twig\Environment->render('_components/hea...', Array)
#24 /home/site/craft/vendor/putyourlightson/craft-sprig-core/src/controllers/ComponentsController.php(64): craft\web\View->renderTemplate('_components/hea...', Array)
#25 [internal function]: putyourlightson\sprig\controllers\ComponentsController->actionRender()
#26 /home/site/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#27 /home/site/craft/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#28 /home/site/craft/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('render', Array)
#29 /home/site/craft/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('render', Array)
#30 /home/site/craft/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('sprig-core/comp...', Array)
#31 /home/site/craft/vendor/craftcms/cms/src/web/Application.php(577): craft\web\Application->runAction('sprig-core/comp...', Array)
#32 /home/site/craft/vendor/craftcms/cms/src/web/Application.php(253): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#33 /home/site/craft/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#34 /home/site/public_html/index.php(22): yii\base\Application->run()
#35 {main}

Next yii\db\Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
The SQL being executed was: SELECT COUNT(*)
FROM (SELECT 1
FROM `sites`
LIMIT 2) `x` in /home/site/craft/vendor/yiisoft/yii2/db/Schema.php:678
Stack trace:
#0 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(1304): yii\db\Schema->convertException(Object(PDOException), 'SELECT COUNT(*)...')
#1 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(1165): yii\db\Command->internalExecute('SELECT COUNT(*)...')
#2 /home/site/craft/vendor/yiisoft/yii2/db/Command.php(433): yii\db\Command->queryInternal('fetchColumn', 0)
#3 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(496): yii\db\Command->queryScalar()
#4 /home/site/craft/vendor/craftcms/cms/src/db/Query.php(259): yii\db\Query->queryScalar('COUNT(*)', NULL)
#5 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(368): craft\db\Query->queryScalar('COUNT(*)', NULL)
#6 /home/site/craft/vendor/craftcms/cms/src/base/ApplicationTrait.php(375): yii\db\Query->count()
#7 /home/site/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1403): craft\web\Application->getIsMultiSite(false, true)
#8 /home/site/craft/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#9 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\elements\db\GlobalSetQuery))
#10 /home/site/craft/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query->createCommand(Object(craft\db\Connection))
#11 /home/site/craft/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#12 /home/site/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1547): craft\db\Query->all(NULL)
#13 /home/site/craft/vendor/craftcms/cms/src/services/Globals.php(542): craft\elements\db\ElementQuery->all()
#14 /home/site/craft/vendor/craftcms/cms/src/services/Globals.php(128): craft\services\Globals->_allSets(1)
#15 /home/site/craft/vendor/craftcms/cms/src/web/twig/Extension.php(1468): craft\services\Globals->getAllSets()
#16 /home/site/craft/vendor/twig/twig/src/ExtensionSet.php(329): craft\web\twig\Extension->getGlobals()
#17 /home/site/craft/vendor/twig/twig/src/Environment.php(928): Twig\ExtensionSet->getGlobals()
#18 /home/site/craft/vendor/twig/twig/src/Environment.php(948): Twig\Environment->getGlobals()
#19 /home/site/craft/vendor/twig/twig/src/Template.php(378): Twig\Environment->mergeGlobals(Array)
#20 /home/site/craft/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#21 /home/site/craft/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#22 /home/site/craft/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#23 /home/site/craft/vendor/craftcms/cms/src/web/View.php(390): Twig\Environment->render('_components/hea...', Array)
#24 /home/site/craft/vendor/putyourlightson/craft-sprig-core/src/controllers/ComponentsController.php(64): craft\web\View->renderTemplate('_components/hea...', Array)
#25 [internal function]: putyourlightson\sprig\controllers\ComponentsController->actionRender()
#26 /home/site/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#27 /home/site/craft/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#28 /home/site/craft/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('render', Array)
#29 /home/site/craft/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('render', Array)
#30 /home/site/craft/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('sprig-core/comp...', Array)
#31 /home/site/craft/vendor/craftcms/cms/src/web/Application.php(577): craft\web\Application->runAction('sprig-core/comp...', Array)
#32 /home/site/craft/vendor/craftcms/cms/src/web/Application.php(253): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#33 /home/site/craft/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#34 /home/site/public_html/index.php(22): yii\base\Application->run()
#35 {main}
Additional Information:
Array
(
    [0] => HY000
    [1] => 2006
    [2] => MySQL server has gone away
)

1 Answer 1

0

The MySQL server has gone away message indicates that the connection to the database was closed, likely because of a request making too many queries or too memory intensive queries. The first step is to track down which requests are causing this, then narrow down which parts of which templates or controller actions and finally optimise the queries. I see a Sprig component is being rendered in the stack trace above, perhaps you can track down the specific template and troubleshoot from there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.