[FIX] base: handle the canceling statement due to lock timeout
A cron `Base: Auto-vacuum internal data` is running, which is performing `auto_vacuum`. When the time limit exceeds 10 secs, we face the above issue. Error: LockNotAvailable: canceling statement due to lock timeout This commit solves the above issue by rollback the statement if the `auto_vacuum` time limit exceeds 10 secs. sentry-3938940519 closes odoo/odoo#131193 X-original-commit: f3dc0e12ba22968697d75c011352c0df99d5b5ed Signed-off-by: Fabien Pinckaers (fp) <fp@odoo.com> Signed-off-by: Archana Vaghasiya (arva) <arva@odoo.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import itertools
|
||||
import logging
|
||||
import mimetypes
|
||||
import os
|
||||
import psycopg2
|
||||
import re
|
||||
import uuid
|
||||
|
||||
@@ -174,7 +175,11 @@ class IrAttachment(models.Model):
|
||||
# but only attempt to grab the lock for a little bit, otherwise it'd
|
||||
# start blocking other transactions. (will be retried later anyway)
|
||||
cr.execute("SET LOCAL lock_timeout TO '10s'")
|
||||
cr.execute("LOCK ir_attachment IN SHARE MODE")
|
||||
try:
|
||||
cr.execute("LOCK ir_attachment IN SHARE MODE")
|
||||
except psycopg2.errors.LockNotAvailable:
|
||||
cr.rollback()
|
||||
return False
|
||||
|
||||
self._gc_file_store_unsafe()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user