All Products
Search
Document Center

Database Autonomy Service:Other lock analysis

Last Updated:Dec 09, 2024

This topic describes how to use the lock analysis feature of Database Autonomy Service (DAS) to analyze metadata lock waits and transaction blocking.

Note
  • In this topic, the data presented in figures is used as test data and is for reference only. In real-world scenarios, parameters such as thread IDs and SQL statements vary based on the actual database environments.

Prerequisites

  • Your database instance runs one of the following database engines:

    • ApsaraDB RDS for MySQL

    • PolarDB for MySQL

  • Your database instance is connected to DAS and is in the Normal Access state. For more information, see Connect a database instance to DAS.

  • DAS Economy Edition or DAS Enterprise Edition is enabled.

    Important
    • DAS Economy Edition and DAS Enterprise Edition are available only in specific regions. For more information, see the Supported databases and regions section of the "DAS editions and supported features" topic.

    • For more information about how to enable DAS Economy Edition or DAS Enterprise Edition, see the Enable DAS Economy Edition and DAS Enterprise Edition section of the "Enable and manage DAS Economy Edition and DAS Enterprise Edition" topic.

Lock types

  • Metadata lock analysis

    • Data analysis: DAS deduces the lock wait relationship and generates the corresponding diagram based on the data in tables such as information_schema.processlist.

  • Transaction blocking analysis

    Important

    The transaction blocking analysis feature is not supported for PolarDB for MySQL clusters that run MySQL 5.6.

    • Data analysis: DAS analyzes the transaction blocking relationship and generates the corresponding diagram based on the information_schema.processlist and information_schema.innodb_trx tables, and the data in the following tables.

      • ApsaraDB RDS for MySQL 5.6 and 5.7: information_schema.innodb_lock_waits

      • PolarDB for MySQL 5.7: information_schema.innodb_lock_waits

      • ApsaraDB RDS for MySQL and PolarDB for MySQL 8.0: performance_schema.data_lock_waits

    • Parameter settings: If the database instance is an ApsaraDB RDS for MySQL 8.0 instance or a PolarDB for MySQL 8.0 cluster, you must set the performance_schema parameter to ON. For more information about how to modify the parameters of a database instance, see one of the following topics based on the database engine of your database instance:

Trigger modes

Lock analysis - triggered analysis

Create an analysis task

  1. Log on to the DAS console.

  2. In the left-side navigation pane, click Instance Monitoring.

  3. On the page that appears, find the database instance that you want to manage and click the instance ID. The instance details page appears.

  4. In the left-side navigation pane, click Lock Analysis. In the Other Lock Analysis section, click Create Analysis Task.

    image.png

View details

Click image before the analysis result to view the metadata lock wait and transaction blocking analysis information. image.png

Transaction lock details

Click View Details in the Actions column of a transaction lock. The details of the transaction lock are displayed by using one of the following methods:

  • List: lists the details of blocked transactions in the transaction lock list. image

  • View: displays the lock details by using the visualized transaction wait relationship. You can click the corresponding session tile to view the details of the session at the bottom. image.png

Metadata lock details

Click View Details in the Actions column of a metadata lock. A view of the metadata lock appears. You can click the corresponding session tile to view the details of the corresponding session at the bottom. You can also perform KILL operations on related sessions. image

Other lock analysis by using SQL Explorer and Audit

If a suspicious session is in the Sleep state and no SQL information is available, a transaction may be enabled for the session. The related SQL statements are executed, but the transaction is not committed or rolled back. In this case, you can click SQL Explorer and Audit in the left-side navigation pane. On the Audit tab, click Enable Advanced Query and enter the thread ID of the suspicious session to query and analyze the SQL statements that were executed in the session. In this example, a lock wait occurs because the transaction is not committed. image.png

Instance sessions - automated analysis

Procedure

  1. Log on to the DAS console.

  2. In the left-side navigation pane, click Instance Monitoring.

  3. On the page that appears, find the database instance that you want to manage and click the instance ID. The instance details page appears.

  4. In the left-side navigation pane, click Instance Sessions. On the Session Management tab, other lock analysis is automatically triggered. The analysis result is displayed in the upper-right corner of the page. image.png

View details on the Instance Sessions page

On the Instance Sessions page, click View Details if a lock wait exists. On the page that appears, you can view the transaction locks and metadata locks. image

Transaction lock details

Click View Details in the Actions column of a transaction lock. You can view the details of the transaction lock in the same manner as you view the details in the "Lock analysis - triggered analysis" section. For more information, see Lock analysis - triggered analysis.

image.png

Metadata lock details

Click View Details in the Actions column of a metadata lock. You can view the details of the metadata lock in the same manner as you view the details in the "Lock analysis - triggered analysis" section. For more information, see the Metadata lock details subsection of the "Lock analysis - triggered analysis" section in this topic.

image.png

View details on the Lock Analysis page

On the Lock Analysis page, click imagebefore the analysis result to view the historical statistics on other lock analysis automatically triggered on the Instance Sessions page. You can view the information in the same manner as you view the details in the "Lock analysis - triggered analysis" section. For more information, see the View details subsection of the "Lock analysis - triggered analysis" section in this topic. image.png

References