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.
Change %s to %r in logstrings
Merge pull request #289 from guidow/job_state_update_in_new_tx

Update job state in separate transactions