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

<p><code>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).</code></p>

<p>Update - also seeing:</p>

<p><code>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&gt;0 AND expire&lt;1485550196.</code></p>

<p>Notes:</p>

<ul>
<li>I'm not using any template level caching (site is Varnished)</li>
<li>My <code>cacheMethod</code> is 'db'</li>
<li>Load balanced setup (1 LB, 2 web heads, 1 LB, 1 DB)</li>
<li>Looking up the key in the latter example, it is a serialized object of <code>Craft\SearchPlus_AlgoliaMapModel</code> (plugin). However, looking at the SearchPlus code I'm pretty it the plugin itself isn't storing this. It has one call to <code>craft()-&gt;cache-&gt;set</code> and it just stores a string.</li>
</ul>

CC BY-SA 3.0
2017-01-27T20:12:50.810Z
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
CC BY-SA 3.0
2017-01-30T15:49:53.823Z
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
<cache><error-message><logs>
craft_cache / Integrity constraint violation: 1062 Duplicate entry, Serialization failure: 1213 Deadlock
# craft_cache / Integrity constraint violation: 1062 Duplicate entry, Serialization failure: 1213 Deadlock

(Asked by: username_0 on 2017-01-27)

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.`

Notes:

* 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.

**Tags:** cache, error-message, logs

> **Comments:**
> **username_1**: 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?  
> **username_0**: 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.  

---

## 0 answers

