[autotest] Wrap heartbeat operations in transactions.
Serializing/deserializing records in and out of the database
needs to be atomic or the scheduler will get confused. Examples
are cases where a job with a metahost is deemed hostless because
of the deserialization delay, or a complete job is thought to be
running because of the delay in setting the status.
TEST=Ran suites across shards.
BUG=chromium:423225
DEPLOY=apache
Change-Id: I058babf3b70399eeb6baa4bf331f962ed2dc4e00
Reviewed-on: https://chromium-review.googlesource.com/232000
Reviewed-by: Prashanth B <beeps@chromium.org>
Tested-by: Prashanth B <beeps@chromium.org>
Commit-Queue: Prashanth B <beeps@chromium.org>
diff --git a/frontend/afe/model_logic.py b/frontend/afe/model_logic.py
index 2566e24..d89de86 100644
--- a/frontend/afe/model_logic.py
+++ b/frontend/afe/model_logic.py
@@ -5,7 +5,11 @@
import re
import time
import django.core.exceptions
-from django.db import models as dbmodels, backend, connection, connections
+from django.db import backend
+from django.db import connection
+from django.db import connections
+from django.db import models as dbmodels
+from django.db import transaction
from django.db.models.sql import query
import django.db.models.sql.where
from django.utils import datastructures
@@ -1093,6 +1097,7 @@
'for type %s' % type(self))
+ @transaction.commit_on_success
def update_from_serialized(self, serialized):
"""Updates local fields of an existing object from a serialized form.