O'Reilly logo

Pro SQL Server Internals by Dmitri Korotkevitch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 19

image

Deadlocks

In a nutshell, a deadlock is just a special blocking case when multiple sessions or, sometimes, even multiple execution threads within a single session block each other.

Classic Deadlock

Classic deadlock occurs when two or more sessions are competing for the same set of resources. Let’s look at a by-the-book example and assume that you have two sessions updating the table. As the first step, session 1 updates the row R1 and session 2 updates the row R2. You know that at this point both sessions acquire and hold exclusive (X) lock on the rows. You can see this happening in Figure 19-1.

Figure 19-1. Classic deadlock, Step ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required