Operations that could lead to task yields were performed during DB transactions, which could lead to deadlocks and timeouts. The code has been changed so that those operations are performed outside DB transactions.

Change-Id: I4597b1a84a4077fd2f22fb0c371b2894304f4276