diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py index 13dc5c1b0c..dd18cd6b1d 100644 --- a/django/core/cache/backends/db.py +++ b/django/core/cache/backends/db.py @@ -65,7 +65,7 @@ class CacheClass(BaseCache): cursor.execute("INSERT INTO %s (cache_key, value, expires) VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)]) except DatabaseError: # To be threadsafe, updates/inserts are allowed to fail silently - transaction.rollback() + transaction.rollback_unless_managed() return False else: transaction.commit_unless_managed()