Updated on 2024-04-11 GMT+08:00

Deadlocks

Scenarios

RDS for SQL Server provides powerful deadlock detection. If there are two processes accessing the same resource at the same time, a deadlock may occur because the processes are waiting for each other to release the resource and cannot continue running. In this case, RDS for SQL Server kills one of the processes so that the other process can complete its transactions.

To solve this problem, the Deadlocks page is provided. On this page, you can quickly locate various types of deadlocks in your instance. The Details area displays information such as transaction start time, session ID, locked resource details, and deadlock mode, helping you locate and optimize problematic SQL statements and other exceptions.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the DB instance name.
  5. In the navigation pane, choose DBA Assistant > Historical Diagnosis.
  6. Click the Deadlocks tab.

    • Deadlocks

      You can view the number of deadlocks in the last day, last week, last two weeks, last month, or in a custom time interval.

    • Deadlocks over Time

      You can view deadlocks over time within a specified period.

      Table 1 Parameter description

      Parameter

      Description

      Total

      Total number of deadlocks.

      Key Lock

      Number of index-related deadlocks.

      Object Lock

      Number of object-related deadlocks.

      Rid Lock

      Number of row deadlocks.

      Page Lock

      Number of page deadlocks.

      Compile Lock

      Number of compilation deadlocks.

      • Details

        You can view details of deadlocks within a specified period.

        To view the deadlock relationship diagram, click Deadlock Diagram in the Operation column. In the displayed dialog box, you can click Download to download the diagram.

        The downloaded deadlock diagram is an XDL file, which can be opened and viewed through the SQL Server Management Studio (SSMS) client.

        Table 2 Parameter description

        Parameter

        Description

        LastTranStarted

        Start time of the transaction.

        SPID

        ID of the session that starts the transaction.

        isVictim

        Whether the session is killed.

        Database

        Name of the database where the transaction is executed.

        LogUsed

        Size of logs that have been generated for the session, in bytes.

        LockMode

        Lock mode.

        WaitResourceDesc

        Details of the resource that the transaction is waiting for.

        ObjectOwned

        Locked object.

        ObjectRequested

        Object that the transaction requests to lock.

        WaitResource

        Resource that the transaction is waiting for.

        HostName

        Host name of the transaction.

        LoginName

        Account name of the transaction.

        Status

        Transaction status.

        ClientApp

        Name of the client used by the transaction.

        SQL

        SQL statement details.

        Operation

        You can view the deadlock diagram.