Execute the lock_id when computing the running values of cron
Closes #15078
This commit is contained in:
@@ -10,7 +10,7 @@ from collections import defaultdict
|
||||
from itertools import groupby
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from sql import Literal
|
||||
from sql import Literal, Select
|
||||
from sql.conditionals import Case, Coalesce
|
||||
from sql.functions import CurrentTimestamp, Extract
|
||||
|
||||
@@ -136,7 +136,11 @@ class Cron(DeactivableMixin, ModelSQL, ModelView):
|
||||
running = defaultdict(bool)
|
||||
if database.has_select_for():
|
||||
# Avoid concurrent locking read
|
||||
database.lock_id(str2bigint(f'{cls.__name__},running'))
|
||||
cursor = transaction.connection.cursor()
|
||||
cursor.execute(*Select([
|
||||
database.lock_id(
|
||||
str2bigint(f'{cls.__name__},running'),
|
||||
True)]))
|
||||
with transaction.new_transaction() as transaction:
|
||||
cursor = transaction.connection.cursor()
|
||||
For = database.get_select_for_skip_locked()
|
||||
|
||||
Reference in New Issue
Block a user