#103139Missing expires in cache_treelist leads to duplicate key value violates unique constraint in the database
Description
In one of my projects I have a lot of “duplicate key value violates unique constraint” errors in the database log:
ERROR: duplicate key value violates unique constraint "cache_treelist_pkey"
DETAIL: Key (md5hash)=(c26b3f85a19047fd109fbb6dc008ede5) already exists.
STATEMENT: INSERT INTO "cache_treelist" ("md5hash", "pid", "treelist", "tstamp") VALUES ($1, $2, $3, $4)
After digging into it, I found out that the cache entry has no expires timestamp which lead to not having a cache at all and the entry is written multiple times per request. In my case twice.