Skip to content
Snippets Groups Projects
Commit 4a213a9d authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[experiments] Improve on job parent searching to avoid double-assignment

parent b6fc8a93
No related branches found
No related tags found
1 merge request!194Scheduler
Pipeline #
...@@ -1020,11 +1020,21 @@ class Block(models.Model): ...@@ -1020,11 +1020,21 @@ class Block(models.Model):
from ..backend.models import Job from ..backend.models import Job
# search for other jobs with similar outputs and has no children yet # search for other jobs with similar outputs that have no children yet
similar = Job.objects.select_for_update().filter(\ # do this carefully, as other experiments may be scheduled at the same
block__outputs__in=self.outputs.all(), child=None).first() # time, invalidating our "parent" choice
parent = Job.objects.filter(block__outputs__in=self.outputs.all(),
Job(block=self, parent=similar).save() child=None).first()
if parent is not None: #(candidate only) try to lock it
while True:
parent = Job.objects.select_for_update().get(pk=parent.pk)
if parent.child_ is not None: #was taken meanwhile, retry
parent = parent.child
continue
Job(block=self, parent=parent).save()
break
else:
Job(block=self).save()
# checks if the job is immediately runnable - if so, tries to # checks if the job is immediately runnable - if so, tries to
# make it runnable (check caches and other) # make it runnable (check caches and other)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment