Changing Isolation Level to Snapshot or Snapshot Read Commited resolve all problems from deadlock ?
thanks
Many deadlock problems are solved because snapshot isolation prevents readers from blocking writers and writers from blocking readers and that is the main cause of deadlocks. Note: Writers still block writers.|||In general - yes: switching to the new isolation levels with non-blocking read access somewhat helps reducing the likelihood of deadlock, but would not completely eliminate them.
However, you should remember that if the application behavior implicitly depends on the blocking semantics of the old isolation levels as implemented in the SQL Engine, the application may stop working correctly when switching to the versioning-based concurrency model. Ideally you should carefully analyze all the transactions in your application and make sure that you don't rely on the subtleties of the implementation of the specific engine and only after that consider switching to the versioning-based transaction isolation.
You should also remember that when using the Snapshot Isolation level your application should also be able to cope with snapshot update conflicts. In other words in this case you trade some deadlocks with (hopefully much less frequent) update conflicts. But again, it all depends on your application.
Pleas also note that despite the Read Committed Snapshot Isolation the SQL Engine never causes update conflicts, it only uses the non-blocking read semantics when accessing tables that are not being updated by the DML statement (unlike the 'normal' snapshot isolation level where all the access to all the tables is truly non-blocking and the data locks necessary for the update/delete are only acquired after the records has been finally selected by the predicate).
Which means that in case of single-table predicated UPDATE/DELETE statements, you don't really enjoy the benefits of the non-blocking access when searching the records to be affected and if most of the deadlock in your application are caused by plain single-table UPDATE/DELETE statements. If so, wou will hardly see any improvements when switching to the Read Committed Snapshot IL from the blocking Read Committed IL.
Of course, the things will most likely improve when switching from Repeatable Read or Serilizable, but since in a multi-statement transaction the Read Committed Snapshot is in fact provides much weaker consistency guarantees compare to either of the above, you have to prove first that the application correctness will not suffer after the switch.
No comments:
Post a Comment