1

I am getting below error every nigth at 00:00. Problem with clean customer visitor. How i can

a:4:{i:0;s:198:"SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction, query was: INSERT INTO `customer_visitor` (`customer_id`, `session_id`, `last_visit_at`) VALUES (?, ?, ?)";i:1;s:12982:"#0 /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(95): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
#2 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)

How can I cleaning up customer_visitor table log. is it creates any problems if cleaning up this table

0

There is a cronjob to clean the customer_visitor table.

vendor/magento/module-customer/etc/crontab.xml

<group id="default">
    <job name="visitor_clean" instance="Magento\Customer\Model\Visitor" method="clean">
        <schedule>0 0 * * *</schedule>
    </job>
</group>

This cronjob will run at middle night At 00:00. So, multi-operations can cause the locks here.

My suggestions:

1) Check your server capacity (RAM, CPU, Hard Driver)

2) As I see, this part can cause database stress if the site has a huge concurrent visitors.

If we're using other tools(Google Analytics, etc..) to track the website, I think we can disable those events. That will reduce the extra load to the database.

For example:

<event name="controller_action_predispatch">
    <observer name="customer_visitor" disabled="true" />
</event>
<event name="controller_action_postdispatch">
    <observer name="customer_visitor" disabled="true" />
</event>

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.