Mitigate the effects of the current DB deadlocks

Due to BZ#958362, we're occasionally getting deadlocks in the DB.
That kills our transaction, which then confuses SQL Alchemy. This
patch is a workaround that at least keeps the daemon from crashing
until we can fix the underlying database issue.

Bug: 950895
Change-Id: Ia743c71b8332e4db0930823d62be8431ca1f4316