Update job state in separate transactions

This is to solve a concurrency issue where sometimes a job's state isn't
set after the last task has been set to DONE or FAILED.
`%r` for the first `%s` for a little easier reading.