Fix unknown race condition in obtaining Result objects
For unclear reasons, multiple Result objects can be created with the same test and machine, despite the ideal situation in that no machine is ever concurrently talking to the server. In the event a duplicate occurs, all future requests would have created an additional duplicate, as Django objects obtained via .get() expect EXACTLY one response. It is unclear how this race condition could have occured in practice
This commit is contained in:
1 parent
9a29658110
commit
1d75616503
1 file changed
+2
-3
@@ -42,9 +42,8 @@ def get_workload(machine):
|
||||
if not (test := select_workload(machine)):
|
||||
return {}
|
||||
|
||||
# Fetch or create the Result object for the test
|
||||
try: result = Result.objects.get(test=test, machine=machine)
|
||||
except: result = Result(test=test, machine=machine)
|
||||
# Avoid creating duplicate Result objects
|
||||
result, created = Result.objects.get_or_create(test=test, machine=machine)
|
||||
|
||||
# Update the Machine's status and save everything
|
||||
machine.workload = test.id;
|
||||
|
||||
Reference in new issue
Block a user