principleMinor
Is it acceptable to use deadlocks as a strategy?
Viewed 0 times
useacceptablestrategydeadlocks
Problem
We recently upgraded our SQL production environment from 2008R2 to 2017. I am finally at a point where I want to try optimistic locking in the form of using snapshot isolation. I read Brent Ozar's article suggesting to SET ALLOW_SNAPSHOT_ISOLATION ON at the database level, and then alter queries to take advantage of the new to us feature. To my surprise, my manager who is very knowledgeable in sql, did not want to move in this direction. I understood him to say that we depended on the deadlocks to prevent us from reading dirty data, and saw no reason to solve a problem that did not exist. I did not know how to respond to him. I have never considered deadlocks as anything other than something to try and eliminate, not depend on as a way of life. I get that they do an important function, but are a sign of something that can be improved.
My question is how many others rely on deadlocks to such an extant that you would not consider trying to eliminate them?
My question is how many others rely on deadlocks to such an extant that you would not consider trying to eliminate them?
Solution
Snapshot and Read Committed Snapshot isolation levels do not prevent deadlocks from happening. They make the engine using row versioning, so readers do not block writers and writers do not block readers as SQLServer does by default. That improves concurrency , but requires changes to the applications that rely on "readers block writers and writers block readers" . I guess you misunderstood your manager , and your system relies on that SQLServer default blocking behavior, not on deadlocks which in most cases can be avoided by application design.
If I happen to work with SQLServer on a new system, I'll surely switch it to use row versioning instead of locking.
However, for an existing system, it is usually safer and cheaper not to fix what is not broken (especially when it's not broken).
If I happen to work with SQLServer on a new system, I'll surely switch it to use row versioning instead of locking.
However, for an existing system, it is usually safer and cheaper not to fix what is not broken (especially when it's not broken).
Context
StackExchange Database Administrators Q#219223, answer score: 4
Revisions (0)
No revisions yet.