From ae9c3cefba66cfd8000a2e7bc79ce5e22aa44c45 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Fri, 20 May 2016 12:43:28 +0200 Subject: [PATCH] [backend] Lock splits which are currently being started --- beat/web/backend/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beat/web/backend/models.py b/beat/web/backend/models.py index 2c4265e4c..5ef26916e 100644 --- a/beat/web/backend/models.py +++ b/beat/web/backend/models.py @@ -424,8 +424,9 @@ class Worker(models.Model): if settings.DEBUG: cmdline += ['-vv'] # start newly assigned job splits - for split in JobSplit.objects.filter(worker=self, status=Job.QUEUED, - start_date__isnull=True, process_id__isnull=True): + for split in JobSplit.objects.select_for_update().filter(worker=self, + status=Job.QUEUED, start_date__isnull=True, + process_id__isnull=True): execute = pick_execute(split, environments) if execute is None: message = "Environment `%s' is not available for split " \ -- GitLab