All Products
Search
Document Center

ApsaraDB RDS:Use the session management feature

Last Updated:Feb 28, 2026

Database Autonomy Service (DAS) provides session management for ApsaraDB RDS for MySQL instances. Monitor active sessions, abnormal sessions, access sources, and SQL statements in real time. Terminate sessions, throttle SQL, run SQL diagnostics, and optimize SQL directly from the console.

Prerequisites

Your RDS instance runs one of the following MySQL versions and editions:

MySQL version

Supported editions

MySQL 8.0

RDS High-availability Edition, RDS Enterprise Edition, RDS Cluster Edition

MySQL 5.7

RDS High-availability Edition, RDS Enterprise Edition, RDS Cluster Edition

MySQL 5.6

RDS High-availability Edition

MySQL 5.5

RDS High-availability Edition

Open session management

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the left-side navigation pane, choose Autonomy Services > Diagnostics.

  3. Click the Session Management tab.

View and manage instance sessions

The Session Management section displays real-time session data: exceptions, active sessions, longest execution duration, CPU utilization, and connection usage.

Analyze SQL within a 10-second window

Click Previous Version in the upper-right corner of the section, then click 10s SQL Analysis. The displayed dialog box displays SQL statistics, slow query logs, and an SQL overview captured within a 10-second window. For details, see 10-second SQL analysis.

Throttle SQL

Click SQL Throttling to open the SQL Throttling panel. Configure threshold-based SQL throttling to limit sessions. For details, see SQL throttling.

Diagnose and optimize SQL

Click Previous Version in the upper-right corner of the section. Select the session and click Optimize to open the SQL Diagnostic Optimizationdialog box and view diagnostic results.

  • To apply a suggestion, click Copy and paste the optimized SQL statement into your database client or Data Management (DMS).

  • To dismiss a suggestion, click Cancel.

    Note

    DAS evaluates SQL complexity, table data volume, and database load during diagnostics. Results may take more than 20 seconds to return. The SQL diagnostic engine provides diagnostic results, optimization suggestions, and expected optimization benefits. Decide whether to accept the suggestions based on the provided information.

Export active sessions

Export active session data from the Instance Sessions section for offline analysis.

Terminate sessions

Select the sessions to terminate. Enter the username and password of the database account that established the sessions, or use a privileged account that has permissions to terminate sessions from other accounts.

  • Check the User column in the session list to identify the database account for each session.

  • Click End Session History to view records of previously terminated sessions.

View session statistics

The Session Statistics section shows summary information: total sessions, total running sessions, and max session runtime. View and export session statistics grouped by user, access source, or database.

Enable automatic SQL throttling

Click Enable Automatic Throttling to turn on automatic SQL throttling. After you configure the trigger conditions, DAS automatically throttles SQL when those conditions are met. This manages the number of access requests and concurrent SQL requests on your instance to maintain database availability. For details, see Automatic SQL throttling.

FAQ

Why does a percent sign (%) appear in the Access Source column?

A percent sign (%) appears in the Access Source column when a session runs through a stored procedure. To reproduce this behavior:

Note

This example uses an RDS for MySQL instance with a test account test_user and a test database testdb.

  1. In the ApsaraDB RDS console, create a database and a standard account, then grant permissions on the database to the standard account. For details, see Create an account.

  2. Connect to the instance using the test_user account through the CLI. For details, see Use a client or the CLI to connect to an ApsaraDB RDS for MySQL instance.

  3. Switch to the testdb database and create a stored procedure:

       -- Switch to the testdb database.
       USE testdb;
    
       -- Create a stored procedure.
       DELIMITER $$
       DROP PROCEDURE IF EXISTS `das` $$
       CREATE DEFINER=`test_user`@`%` PROCEDURE `das`()
       BEGIN
       SELECT * FROM information_schema.processlist WHERE Id = CONNECTION_ID();
       END $$
       DELIMITER;
  4. Connect to the instance using a privileged account. For details, see Step 2: Connect to an ApsaraDB RDS for MySQL instance.

  5. Call the stored procedure.

    Expected output: The HOST column displays %:2065 because the stored procedure was defined with DEFINER='test_user'@'%', and the session inherits this host value when the procedure runs under a privileged account.

       -- Switch to the testdb database.
       USE testdb;
    
       -- Call the stored procedure.
       CALL das();
       +--------+-----------+--------+--------+---------+------+-----------+-------------------------------------------------------------------------+
       | ID     | USER      | HOST   | DB     | COMMAND | TIME | STATE     | INFO                                                                    |
       +--------+-----------+--------+--------+---------+------+-----------+-------------------------------------------------------------------------+
       | 487818 | test_user | %:2065 | testdb | Query   |    0 | executing | SELECT * FROM information_schema.processlist WHERE Id = CONNECTION_ID() |
       +--------+-----------+--------+--------+---------+------+-----------+-------------------------------------------------------------------------+

What sessions are marked as abnormal?

DAS marks the following sessions as abnormal:

  • Blocking SQL statements with execution duration exceeding 30 seconds, such as sessions reporting "Waiting for table metadata lock." Common blocking SQL includes DDL statements and FLUSH TABLES WITH READ LOCK. These statements occupy resources for extended periods and may prevent other SQL statements from running.

  • Long-running transactions with duration exceeding 30 seconds.

  • Uncommitted transactions where no new SQL statements have been executed for more than 10 seconds after the transaction started. This typically indicates a missing COMMIT command in the code, causing the transaction to hold resources without releasing them.

References

DAS autonomy features can automatically diagnose and optimize SQL statements in your database sessions: