RetryOnDeadlock ( System.Action method ) : void |
Retries the given operation in the case of a deadlock (when using pessimistic concurrency) or snapshot isolation error (when using optimistic concurrency) until it succeeds. NEVER EVER use this inside a transaction because SQL will automatically kill the transaction in the case of a deadlock, and it's unusable after that point. In the case of Snapshots, the same snapshot from the beginning of the transaction will be used every single time, and so the operation will fail every single time. So, again, DO NOT use this inside a transaction. When using this method, it is important that DeadLockableMethod does not produce any side effects (changing state, sending an email, etc.). Undoing/resetting side effects at the beginning of the block of code to be retried is an acceptable approach here (there is no way to undo certain operations, such as sending an email, obviously). |
|