MySQL deadlock, wait for resources, transaction lock, lock wait timeout exceeded; Try restarting Transaction solution

Source: Internet
Author: User

The previous understanding of InnoDB on the occurrence of lock waiting, will be based on the configuration of the parameters Innodb_lock_wait_timeout, determine whether to do a timeout operation, this document describes in the presence of lock waiting time to view and analyze processing;

Before InnoDB plugin, it is common to see the current database request through Show full processlist (it is difficult to find the locked line to record the problem) and the show Engine InnoDB status command. It then determines the condition of the lock in the current transaction. With the development of MySQL, more convenient methods have been provided to monitor the lock waiting in the database.

There are three tables under Information_schema : Innodb_trx, Innodb_locks, innodb_lock_waits (Problem solving), through these three sheets, You can more easily monitor your current transactions and analyze possible problems.

Comparison of commonly used columns:

Trx_id:innodb The only thing ID inside the storage engine
Trx_status: Status of the current transaction
Trx_status: Start time of transaction
TRX_REQUESTED_LOCK_ID: The lock ID of the waiting transaction
Trx_wait_started: The start time of the transaction wait
Trx_weight: The weight of the transaction, which reflects the number of rows modified and locked by a transaction, the smaller the weight value is rolled back when a deadlock is found to be rolled back
The process ID in Trx_mysql_thread_id:mysql, corresponding to the ID value in show processlist
Trx_query: SQL statement run by transaction

Kill process ID; A vehicle record was encountered at work, select * from car for update or to modify the value of a field, error: Lock wait timeout exceeded; Try restarting transaction solution, in addition to fundamentally from the Business logic code optimization of the operation of the database, have encountered such a situation before, such as just modified this record, and then modify again, will report this error, from the code and business level to avoid.

MySQL deadlock, wait for resources, transaction lock, lock wait timeout exceeded; Try restarting Transaction solution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.