Yii Framework Forum: Cdbcache Duplicate Primary Keys - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cdbcache Duplicate Primary Keys Rate Topic: -----

#1 User is offline   unique_yikes 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 30-August 10

Posted 16 April 2013 - 05:21 AM

Hi,

We have a rather big CRM built on top of Yii. There's one constant problem in application log to do with CDbCache:



2013/04/16 10:50:45 [error] [system.db.CDbCommand]

  CDbCommand::execute() failed: SQLSTATE[23000]: Integrity constraint

  violation: 1062 Duplicate entry '3c6dfaf87ff9f3fa382f52fc26b9b3cc' for key 'PRIMARY'. The SQL statement executed was: INSERT INTO YiiCache

  (id,expire,value) VALUES

  ('3c6dfaf87ff9f3fa382f52fc26b9b3cc',1366106445,:value).



By the looks of it, application tries to cache the same thing twice at the same time. The first save of cache succeeds, while the second one throws that error (only in application log, the actual application doesn't crash). We use minScript (http://www.yiiframew...sion/minscript/) with database as a cache, so most of the values which are cached are css and js files, but things like table schema are sometimes being put twice as well.

PHP: 5.3.13
MySQL: 5.1.68
Yii: 1.1.13, but happened with previous versions also

Is this a bug, or is it an expected behaviour?
For reproduction, it is hard to do it, as it happens randomly, and I couldn't make it throw this error when I wanted to.
0

#2 User is offline   Emile Bons 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 19-September 11
  • Location:Breda, The Netherlands

Posted 04 April 2014 - 03:27 AM

This is a rather old topic, but I'm facing the same right now. Anyone experienced this and have a clue of how to fix it? Some background information: I'm just trying to cache the output of a CActiveRecord findAll method:

$c = new CDbCriteria();
$c->with = 'memberMetas';
$c->condition = 'dataset_id=:dataset_id and ts>=:start_ts and ts<:end_ts and `key`=:key and value=:value';
$c->params = self::dbParams($statistics);
$dependency = new CDbCacheDependency('SELECT MAX(ts) FROM sts_member');
$statistics->members = Member::model()->cache(1000, $dependency)->findAll($c);


The same error occurs as described by unique_yikes on the last line where I query the db.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users