mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
avoid instance record deadlock by using pglock
This commit is contained in:
parent
5ab1a76785
commit
f1b1c4ee97
@ -9,7 +9,6 @@ from sets import Set
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import transaction, connection
|
||||
from django.db.utils import DatabaseError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now as tz_now
|
||||
|
||||
@ -24,6 +23,8 @@ from awx.main.tasks import _send_notification_templates
|
||||
# Celery
|
||||
from celery.task.control import inspect
|
||||
|
||||
from django_pglocks import advisory_lock
|
||||
|
||||
logger = logging.getLogger('awx.main.scheduler')
|
||||
|
||||
|
||||
@ -459,13 +460,12 @@ class TaskManager():
|
||||
logger.debug("Starting Schedule")
|
||||
with transaction.atomic():
|
||||
# Lock
|
||||
try:
|
||||
Instance.objects.select_for_update(nowait=True).all()[0]
|
||||
except DatabaseError:
|
||||
return
|
||||
with advisory_lock('task_manager_lock', wait=False) as acquired:
|
||||
if acquired is False:
|
||||
return
|
||||
|
||||
finished_wfjs = self._schedule()
|
||||
finished_wfjs = self._schedule()
|
||||
|
||||
# Operations whose queries rely on modifications made during the atomic scheduling session
|
||||
for wfj in WorkflowJob.objects.filter(id__in=finished_wfjs):
|
||||
_send_notification_templates(wfj, 'succeeded' if wfj.status == 'successful' else 'failed')
|
||||
# Operations whose queries rely on modifications made during the atomic scheduling session
|
||||
for wfj in WorkflowJob.objects.filter(id__in=finished_wfjs):
|
||||
_send_notification_templates(wfj, 'succeeded' if wfj.status == 'successful' else 'failed')
|
||||
|
||||
3
docs/licenses/django-pglocks.txt
Normal file
3
docs/licenses/django-pglocks.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Copyright (c) 2013 Christophe Pettus
|
||||
|
||||
Licensed under the MIT License.
|
||||
@ -16,6 +16,7 @@ django-crum==0.7.1
|
||||
django-extensions==1.7.8
|
||||
django-jsonfield==1.0.1
|
||||
django-polymorphic==1.2
|
||||
django-pglocks==1.0.2
|
||||
django-radius==1.1.0
|
||||
django-solo==1.1.2
|
||||
django-split-settings==0.2.5
|
||||
|
||||
@ -59,6 +59,7 @@ django-crum==0.7.1
|
||||
django-extensions==1.7.8
|
||||
django-jsonfield==1.0.1
|
||||
django-polymorphic==1.2
|
||||
django-pglocks==1.0.2
|
||||
django-radius==1.1.0
|
||||
django-solo==1.1.2
|
||||
django-split-settings==0.2.5
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user