Cache - PDOException with "Duplicate entry for key 'PRIMARY'"

375 views
Skip to first unread message

Ondřej Šatera

unread,
Nov 16, 2014, 3:50:27 AM11/16/14
to not...@googlegroups.com
Hi, I have a problem with NotORM since I've started using NotORM_Cache_Database. I'm receiving exceptions with this content:

PHP Fatal error: Uncaught exception PDOException with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'stages;act' for key 'PRIMARY'' in /***/NotORM/Result.php:448  @  http://www.wulflund.com/en/search/list/?vp-page=1

PHP Fatal error: Uncaught exception PDOException with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'store_goods;goods_id,size_value_id,store_id' for key 'PRIMARY'' in /***/NotORM/Result.php:448  @  http://www.wulflund.com/fr/order/confirm/?do=confirmForm-submit

The weird thing is that only some users receive this error. I cannot easily replicate it. My theory is that it is somehow bound to user's session.

My initialization of NotORM looks like this:
$connection = new PDO ( "mysql:dbname=***; host=*** );
$connection->exec('SET CHARACTER SET utf8');
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connection->errorInfo();

$notORMCache = new NotORM_Cache_Database($connection);

$notORM = new NotORM (
$connection,
new NotORM_Structure_Discovery($connection, $notORMCache),
$notORMCache
);

The project is using Nette in version 2.0 and the servers runs on PHP 5.3.

Jakub Vrana

unread,
Nov 16, 2014, 2:33:31 PM11/16/14
to not...@googlegroups.com
This looks more like an application error than a NotORM error. Aren't
you expecting auto_increment on some column where it actually isn't
defined? Or aren't you setting such column to some value manually?

Jakub

On 11/16/2014 12:50 AM, Ondřej Šatera wrote:
> Hi, I have a problem with NotORM since I've started
> using NotORM_Cache_Database. I'm receiving exceptions with this content:
> |
>
> PHP Fatalerror:Uncaughtexception PDOExceptionwithmessage
> 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
> 'stages;act' for key
> 'PRIMARY''in/***/NotORM/Result.php:448@http://www.wulflund.com/en/search/list/?vp-page=1
> <http://www.wulflund.com/en/search/list/?vp-page=1>
>
> |
> |
>
> PHP Fatalerror:Uncaughtexception PDOExceptionwithmessage
> 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
> 'store_goods;goods_id,size_value_id,store_id' for key
> 'PRIMARY''in/***/NotORM/Result.php:448@http://www.wulflund.com/fr/order/confirm/?do=confirmForm-submit
> <http://www.wulflund.com/fr/order/confirm/?do=confirmForm-submit>
>
> |
> The weird thing is that only some users receive this error. I cannot
> easily replicate it. My theory is that it is somehow bound to user's
> session.
>
> My initialization of NotORM looks like this:
> |
> $connection = new PDO ( "mysql:dbname=***; host=*** );
> $connection->exec('SET CHARACTER SET utf8');
> $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
> $connection->errorInfo();
>
> $notORMCache = new NotORM_Cache_Database($connection);
>
> $notORM = new NotORM (
> $connection,
> new NotORM_Structure_Discovery($connection, $notORMCache),
> $notORMCache
> );
> |
>
> The project is using Nette in version 2.0 and the servers runs on PHP 5.3.
>
> --
> You received this message because you are subscribed to the Google
> Groups "NotORM" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to notorm+un...@googlegroups.com
> <mailto:notorm+un...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Ondřej Šatera

unread,
Nov 16, 2014, 2:45:40 PM11/16/14
to not...@googlegroups.com
Well it was working before without any problem. These exceptions started to show up when I've set there the caching. Most of the exceptions come from the search page where are no INSERTs or UPDATEs. So there has to be something wrong with the caching. The weirdest thing is the dependecy on session. I still haven't managed to replicate the error. 

Is there some dependency on user's session?

Dne neděle, 16. listopadu 2014 20:33:31 UTC+1 Jakub Vrána napsal(a):
Reply all
Reply to author
Forward
0 new messages