Noticing these errors a lot it my logs. Any idea why, or how to stop it from happening?

Jan 27 15:02:58 myapp.com ool: myapp: [craft] [error] [system.db.CDbCommand] CDbCommand::execute() failed: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'b790ee3c633c1693d2140bfae35b65fe' for key 'PRIMARY'. The SQL statement executed was: INSERT INTO craft_cache (id,expire,value) VALUES ('b790ee3c633c1693d2140bfae35b65fe',1485633775,:value).

Update - also seeing:

Jan 27 15:49:58 myapp.com ool: myapp: [craft] [error] [system.db.CDbCommand] CDbCommand::execute() failed: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction. The SQL statement executed was: DELETE FROM craft_cache WHERE expire>0 AND expire<1485550196.


  • I'm not using any template level caching (site is Varnished)
  • My cacheMethod is 'db'
  • Load balanced setup (1 LB, 2 web heads, 1 LB, 1 DB)
  • Looking up the key in the latter example, it is a serialized object of Craft\SearchPlus_AlgoliaMapModel (plugin). However, looking at the SearchPlus code I'm pretty it the plugin itself isn't storing this. It has one call to craft()->cache->set and it just stores a string.
  • The error is pretty clear... can you catch a full stack trace with devMode enabled so you can see which template it's originating from? – Brad Bell Jan 27 '17 at 20:12
  • That's a bit tricky as I'm only currently seeing it in production. I added several more details in the original post. I'm more just curious how this is even possible through a simple craft()->cache->set / CDbCache\setValue call. – Tim Kelty Jan 30 '17 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.