0
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '154381' for key 'PRIMARY'
Trace:
#0 /home4/cctvmal1/public_html/lib/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home4/cctvmal1/public_html/lib/Zend/Db/Adapter/Abstract.php(457): Zend_Db_Statement->execute(Array)
#2 /home4/cctvmal1/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(230): Zend_Db_Adapter_Abstract->query('INSERT INTO `lo...', Array)
#3 /home4/cctvmal1/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(281): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `lo...', Array)
#4 /home4/cctvmal1/public_html/lib/Zend/Db/Adapter/Abstract.php(535): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `lo...', Array)
#5 /home4/cctvmal1/public_html/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(125): Zend_Db_Adapter_Abstract->insert('log_visitor_inf...', Array)
#6 /home4/cctvmal1/public_html/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(79): Mage_Log_Model_Mysql4_Visitor->_saveVisitorInfo(Object(Mage_Log_Model_Visitor))
#7 /home4/cctvmal1/public_html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(373): Mage_Log_Model_Mysql4_Visitor->_afterSave(Object(Mage_Log_Model_Visitor))
#8 /home4/cctvmal1/public_html/app/code/core/Mage/Core/Model/Abstract.php(251): Mage_Core_Model_Mysql4_Abstract->save(Object(Mage_Log_Model_Visitor))
#9 /home4/cctvmal1/public_html/app/code/core/Mage/Log/Model/Visitor.php(159): Mage_Core_Model_Abstract->save()
#10 /home4/cctvmal1/public_html/app/code/core/Mage/Core/Model/App.php(1239): Mage_Log_Model_Visitor->initByRequest(Object(Varien_Event_Observer))
#11 /home4/cctvmal1/public_html/app/Mage.php(303): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#12 /home4/cctvmal1/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(454): Mage::dispatchEvent('controller_acti...', Array)
#13 /home4/cctvmal1/public_html/app/code/core/Mage/Core/Controller/Front/Action.php(45): Mage_Core_Controller_Varien_Action->preDispatch()
#14 /home4/cctvmal1/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(365): Mage_Core_Controller_Front_Action->preDispatch()
#15 /home4/cctvmal1/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch('index')
#16 /home4/cctvmal1/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 /home4/cctvmal1/public_html/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#18 /home4/cctvmal1/public_html/index.php(65): Mage::run()
#19 {main}           
1

it means you're using the same primary key value twice in the same table. There is already a product with the ID of 154381 in log_visitor, and a query is trying to save a new record with that ID again. If you are inserting records, make sure you are picking brand new record id or that the combination of record id and the other column is unique.

  • This is not wrong, but judging by the stack trace this is not coming from custom code, but straight away from Mage_Log. There should be a solution without having to fix this core module. – Fabian Schmengler Sep 20 '16 at 13:41
1

This looks like a mismatch between the visitor log tables, perhaps caused by an incomplete log cleaning.

If you truncate both tables it should get things running again.

TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
0

This might be a good chance to improve your shop performance by disabling Magentos visitor logging. There is usually no reason to use that and in your case it's throwing errors for some reason.

You can copy the following configuration to your app/etc/local.xml or a custom module's config.xml to disable the visitor logging observers:

<config>

    <frontend>

        <events>
            <controller_action_predispatch>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </controller_action_predispatch>
            <controller_action_postdispatch>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </controller_action_postdispatch>
            <customer_login>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </customer_login>
            <customer_logout>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </customer_logout>
            <sales_quote_save_after>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </sales_quote_save_after>
            <checkout_quote_destroy>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </checkout_quote_destroy>
        </events>
    </frontend>

</config>

These observers result in additional database queries on every page request. It is not related to useful logging like Google Analytics, error logs or webserver access logs.

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.