Gravity: Method for handling deadlocks and reexecuting the query