El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Ending Idle Transactions

Updated on 2024-07-02 GMT+08:00

Introduction

If an idle transaction is not committed for a long time, its rollback will consume database resources and performance. If a large number of idle transactions are not committed and not rolled back for a long time, the performance loss to a database is severe especially during peak hours.

Characteristics

Huawei Cloud RDS for MySQL supports idle transaction disconnection when a rollback timed out. This function has the following characteristics:

  • Different parameters are used to control different types of transactions.
  • When idle transactions timed out, they are automatically rolled back and disconnected.

Description

Run show variables to query related parameters.

show variables like '%idle%';
+------------------------------------+------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| idle_readonly_transaction_timeout | 0     |
| idle_transaction_timeout          | 0     |
| idle_write_transaction_timeout    | 0     |
+-----------------------------------+-------+
Table 1 Parameter description

Parameter

Type

Value Range

Dynamic Validation

Description

idle_readonly_transaction_timeout

integer

Positive integer

Yes

Time in seconds that the server waits for idle read-only transactions before killing the connection. If this parameter is set to 0, there is not timeout threshold for idle read-only transactions.

idle_transaction_timeout

integer

Positive integer

Yes

Time in seconds that the server waits for common idle transactions before killing the connection. If this parameter is set to 0, there is not timeout threshold for common idle transactions.

NOTE:

The parameters idle_readonly_transaction_timeout and idle_write_transaction_timeout have higher priorities than the parameter idle_transaction_timeout.

  • If you set a value for idle_readonly_transaction_timeout or idle_write_transaction_timeout and validate the value, idle_transaction_timeout becomes invalid.
  • If only the parameter idle_transaction_timeout has been set and validated, the value of this parameter is used as the timeout interval for read and write operations on transactions.

idle_write_transaction_timeout

integer

Positive integer

Yes

Time in seconds that the server waits for idle read/write transactions before killing the connection. If this parameter is set to 0, there is not timeout threshold for idle read/write transactions.

Application Scenarios

The parameters are set as follows.
show variables like '%idle%';
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| idle_readonly_transaction_timeout | 5     |
| idle_transaction_timeout          | 10    |
| idle_write_transaction_timeout    | 15    |  
+-----------------------------------+-------+
  • Setting idle_readonly_transaction_timeout

    Set idle_readonly_transaction_timeout to 5.

    1. Run the begin statement to start a transaction and run a query statement. The following information is displayed.
      begin;
      Query OK, 0 rows affected (0.00 sec)
      select * from t1;
      +-----+-----+-----+-----+
      | a   |  b  |  c  | d   | 
      +-----+-----+-----+-----+
      | 1   |  b  | 303 | d   |
      +-----+-----+-----+-----+
      1 row in set (0.00 sec)
    2. Wait for five seconds and run a query statement again. The following information is displayed.
      select * from t1;
      +-----+-----+-----+-----+
      | a   |  b  |  c  | d   | 
      +-----+-----+-----+-----+
      | 1   |  b  | 303 | d   |
      +-----+-----+-----+-----+
      1 row in set (0.00 sec)
      select * from t1;
      ERROR 2006(HY000): MySQL server has gone away
  • Setting idle_transaction_timeout, idle_readonly_transaction_timeout, and idle_write_transaction_timeout
    Set idle_transaction_timeout to 10, idle_readonly_transaction_timeout to 0, and idle_write_transaction_timeout to 0.
    show variables like '%idle%';
    +-----------------------------------+-------+
    | Variable_name                     | Value |
    +-----------------------------------+-------+
    | idle_readonly_transaction_timeout | 0     |
    | idle_transaction_timeout          | 10    |
    | idle_write_transaction_timeout    | 0     |
    +-----------------------------------+-------+
    3 rows in set (0.01 sec)
    • Read-only transactions

      When idle_readonly_transaction_timeout is set to 0, the idle_transaction_timeout parameter takes effect.

      1. Run the begin statement to start a transaction and run a statement to query the table data. The following information is displayed.
        begin;
        Query OK, 0 rows affected (0.00 sec)
        select * from t1;
        +-----+-----+-----+-----+
        | a   |  b  |  c  | d   | 
        +-----+-----+-----+-----+
        | 1   |  b  |  43 | d   |
        +-----+-----+-----+-----+
        1 row in set (0.00 sec)
      2. Wait for 10 seconds and run a query statement again. The following information is displayed.
        select * from t1;
        ERROR 2006(HY000): MySQL server has gone away
    • Read/write transactions

      When idle_write_transaction_timeout is set to 0, the idle_transaction_timeout parameter takes effect.

      1. Run the begin statement to start a transaction, insert data, and run a query statement within 10 seconds. The following information is displayed.
        begin;
        Query OK, 0 rows affected (0.00 sec)
        INSERT INTO t1(a,b,c,d) VALUES (1,'b',FLOOR( 1 + (RAND()*1000)) ,'d');
        Query OK, 1 rows affected (0.00 sec)
        select * from t1;
        +-----+-----+-----+-----+
        | a   |  b  |  c  | d   | 
        +-----+-----+-----+-----+
        | 1   |  b  |  425 | d   |
        +-----+-----+-----+-----+
        1 row in set (0.00 sec)
      2. Wait for 10 seconds and run a query statement again. The following information is displayed.
        select * from t1;
        ERROR 2006(HY000): MySQL server has gone away
      3. Independently run a statement to query the table. If the following information is displayed, the transaction has been rolled back.
        select * from t1;
        Empty set (0.00 sec)
  • Setting idle_write_transaction_timeout

    Set idle_write_transaction_timeout to 15.

    1. Run the begin statement to start a transaction and then insert a data record. The following information is displayed.
      begin;
      Query OK, 0 rows affected (0.00 sec)
      INSERT INTO t1(a,b,c,d) VALUES (1,'b',FLOOR( 1 + (RAND()*1000)) ,'d');
      Query OK, 1 rows affected (0.00 sec)
    2. Run a query statement within 15 seconds of the time range specified by idle_write_transaction_timeout. The following information is displayed.
      select * from t1;
      +-----+-----+-----+-----+
      | a   |  b  |  c  | d   | 
      +-----+-----+-----+-----+
      | 1   |  b  | 987 | d   |
      +-----+-----+-----+-----+
      1 row in set (0.00 sec)
    3. Wait for 15 seconds and run a query statement again. The following information is displayed.
      select * from t1;
      ERROR 2006(HY000): MySQL server has gone away
    4. Reconnect the transaction to the database and run a query statement. If the following information is displayed, the transaction has been rolled back.
      select * from t1;
      Empty set (0.00 sec)

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback