[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>
2 files changed