[FIX] base: mute SE in cron acquire job

Commit c06cee44fe corrected a nasty concurrency error in crons but the
serialization error was still logged.

closes odoo/odoo#98741

X-original-commit: 81c70a594a785fc0e32c9ff47c28c92b0f837923
Signed-off-by: Julien Castiaux <juc@odoo.com>
This commit is contained in:
Julien Castiaux
2022-08-24 13:25:01 +02:00
parent 6f30abe258
commit 7314bad7b4
+13 -2
View File
@@ -240,7 +240,7 @@ class ir_cron(models.Model):
#
# Learn more: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-ROWS
cr.execute("""
query = """
SELECT *
FROM ir_cron
WHERE active = true
@@ -256,7 +256,18 @@ class ir_cron(models.Model):
AND id in %s
ORDER BY priority
LIMIT 1 FOR NO KEY UPDATE SKIP LOCKED
""", [job_ids])
"""
try:
cr.execute(query, [job_ids], log_exceptions=False)
except psycopg2.extensions.TransactionRollbackError:
# A serialization error can occurs when anoter cron worker
# commits the new `nextcall` value of a cron it just ran and
# that commit occured just before this query. The error is
# genuine and the job should be skipped in this cron worker.
raise
except Exception as exc:
_logger.error("bad query: %s\nERROR: %s", query, exc)
raise
return cr.dictfetchone()
@classmethod