Deadlock retries

Retry transaction on deadlock error.
Agreed about consolidating the raise. I find the unless operator confusing in all but simplest conditions, so I opted for altering the if / else to include the retry_count check.