You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/relational-databases/performance/optimized-locking.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: "Learn about the optimized locking enhancement to the Database Engi
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
6
ms.reviewer: randolphwest, peskount
7
-
ms.date: 10/04/2023
7
+
ms.date: 10/09/2023
8
8
ms.service: sql
9
9
ms.subservice: performance
10
10
ms.topic: conceptual
@@ -229,7 +229,7 @@ To support monitoring and troubleshooting of blocking and deadlocking with optim
229
229
- Wait resource visibility
230
230
-`XACT` wait resources. For more information, see `wait_resource` in [sys.dm_exec_requests (Transact-SQL)](../system-dynamic-management-views/sys-dm-exec-requests-transact-sql.md).
231
231
- Deadlock graph
232
-
- Under each resource in the deadlock report's `<resource-list>`, each `<xactlock>` element reports the underlying resources and specific information for locks of each member of a deadlock.
232
+
- Under each resource in the deadlock report's `<resource-list>`, each `<xactlock>` element reports the underlying resources and specific information for locks of each member of a deadlock. For more information and an example, see [Optimized locking and deadlocks](../sql-server-deadlocks-guide.md#optimized-locking-and-deadlocks).
Copy file name to clipboardExpand all lines: docs/relational-databases/sql-server-deadlocks-guide.md
+52-5Lines changed: 52 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: "Learn about deadlocks in the SQL Server database engine."
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
6
ms.reviewer: randolphwest
7
-
ms.date: 03/21/2023
7
+
ms.date: 10/09/2023
8
8
ms.service: sql
9
9
ms.subservice: performance
10
10
ms.topic: conceptual
@@ -509,7 +509,57 @@ You can view the XML in the `Deadlock_XML` column inside SSMS, by selecting the
509
509
510
510
:::image type="content" source="media/sql-server-deadlocks-guide/graphical-deadlock-xdl.png" alt-text="A screenshot of a visual deadlock graph in an .xdl file in SSMS." lightbox="media/sql-server-deadlocks-guide/graphical-deadlock-xdl.png":::
[Optimized locking](performance/optimized-locking.md) introduced a different method for locking mechanics that changes how deadlocks involving exclusive TID locks may be reported. Under each resource in the deadlock report's `<resource-list>`, each `<xactlock>` element reports the underlying resources and specific information for locks of each member of a deadlock.
517
+
518
+
Consider the following example where optimized locking is enabled:
519
+
520
+
```sql
521
+
CREATETABLEt2
522
+
(a intPRIMARY KEYnot null
523
+
,b intnull);
524
+
525
+
INSERT INTO t2 VALUES (1,10),(2,20),(3,30)
526
+
GO
527
+
```
528
+
529
+
The following TSQL commands in two sessions will create a deadlock on table `t2`:
530
+
531
+
In session 1:
532
+
533
+
```sql
534
+
--session 1
535
+
begin tran foo;
536
+
update t2 set b = b+10where a =1;
537
+
```
538
+
539
+
In session 2:
540
+
```sql
541
+
--session 2:
542
+
begin tran bar
543
+
update t2 set b = b+10where a =2;
544
+
```
545
+
546
+
In session 1:
547
+
```sql
548
+
--session 1:
549
+
update t2 set b = b +100where a =2;
550
+
```
551
+
552
+
In session 2:
553
+
```sql
554
+
--session 2:
555
+
update t2 set b = b +20where a =1;
556
+
```
557
+
558
+
This results in a deadlock. In this case, a keylock resource, where each session holds an X lock on its own TID and is waiting on the S lock on the other TID, resulting in a deadlock. The following XML, captured as the deadlock report, contains elements and attributes specific to optimized locking:
559
+
560
+
:::image type="content" source="media/sql-server-deadlocks-guide/optimized-locking-tid-lock-deadlock-xml.png" alt-text="A screenshot of the XML of a deadlock report showing the UnderlyingResource nodes and keylock nodes specific to optimized locking." lightbox="media/sql-server-deadlocks-guide/optimized-locking-tid-lock-deadlock-xml.png":::
-[Analyze and prevent deadlocks in Azure SQL Database](/azure/azure-sql/database/analyze-prevent-deadlocks)
525
572
-[Open, view, and print a deadlock file in SQL Server Management Studio (SSMS)](performance/open-view-and-print-a-deadlock-file-sql-server-management-studio.md)
0 commit comments