Lock cron table at the transaction starts

If the lock is not taken at the transaction starts since c8771e45b861 an
exception is raised.

Closes #12248
This commit is contained in:
Cédric Krier
2023-05-02 14:34:37 +02:00
parent c8095a1a84
commit 05a0b221d1
+3 -2
View File
@@ -161,10 +161,11 @@ class Cron(DeactivableMixin, ModelSQL, ModelView):
logger.info('cron started for "%s"', db_name)
now = datetime.datetime.now()
retry = config.getint('database', 'retry')
with transaction.start(db_name, 0, context={'_skip_warnings': True}):
with transaction.start(
db_name, 0, context={'_skip_warnings': True},
_lock_tables=[cls._table]):
pool = Pool()
Error = pool.get('ir.error')
cls.lock()
crons = cls.search(['OR',
('next_call', '<=', now),
('next_call', '=', None),