Server Error 500 and SQLSTATE[23000]


(Edoardo) #1

Hi there,

I recently started noticing that my piwik installation (v.0.4.5) is reporting a frightening amount of 500 server errors from the PHP log (incoming tracking calls).
The PHP log reports:

[28-Nov-2009 18:55:32] PHP Fatal error: Uncaught exception 'Exception' with message 'Error query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '191104' for key 'PRIMARY' In query: /* SHARDING_ID_SITE = 1 */ INSERT INTO piwik_log_link_visit_action (idvisit, idaction, idaction_ref, time_spent_ref_action) VALUES (?,?,?,?) Parameters: array ( 0 => '107138', 1 => '1', 2 => 0, 3 => 0, )' in C:\Inetpub\AppRoot\piwik\core\Tracker\Db\Pdo\Mysql.php:178 Stack trace: #0 C:\Inetpub\AppRoot\piwik\core\Tracker\Action.php(180): Piwik_Tracker_Db_Pdo_Mysql->query('/* SHARDING_ID_...', Array) #1 C:\Inetpub\AppRoot\piwik\core\Tracker\Visit.php(162): Piwik_Tracker_Action->record('107138', 0, 0) #2 C:\Inetpub\AppRoot\piwik\core\Tracker.php(67): Piwik_Tracker_Visit->handle() #3 C:\Inetpub\AppRoot\piwik\piwik.php(74): Piwik_Tracker->main() #4 {main} thrown in C:\Inetpub\AppRoot\piwik\core\Tracker\Db\Pdo\Mysql.php on line 178
Can anybody help me with this?

Thank you.


(vipsoft) #2

That looks like a database in need of repair. The query is inserting ‘107138’ not ‘191104’ …

Are you running php5.3 by chance?


(Edoardo) #3

[quote=vipsoft @ Nov 28 2009, 11:36 PM]That looks like a database in need of repair. The query is inserting ‘107138’ not ‘191104’ …

Are you running php5.3 by chance?[/quote]

Not now but I did for a few days before having to rollback for a variety of issues.
Any idea on how to fix things?

Thank you!


(vipsoft) #4

MyISAM tables aren’t auto-repaired by a server restart, so you’ll have to do this manually.

The MySQL site documentation (mysql.com) will explain how to check and repair errors for your specific mysql version.

eg (MySQL :: MySQL 5.7 Reference Manual :: 7.6.3 How to Repair MyISAM Tables )


(Edoardo) #5

[quote=vipsoft @ Nov 29 2009, 06:46 AM]MyISAM tables aren’t auto-repaired by a server restart, so you’ll have to do this manually.

The MySQL site documentation (mysql.com) will explain how to check and repair errors for your specific mysql version.

eg (MySQL :: MySQL 5.7 Reference Manual :: 7.6.3 How to Repair MyISAM Tables )[/quote]

Ah! That fixed the issue. Thank you!