MySQL deadlock causes query failure

Source: Internet
Author: User

During database maintenance recently, data cannot be stored into the database during data parsing. The reason is that MySQL transactions have deadlocked. I restarted MySQL several times before.

Recent frequent occurrences. So find a method.

SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;

Trx_id trx_state trx_started too many trx_weight too trx_query trx_operation_state too many trx_state trx_started too many trx_weight too trx_query too many trx_last_foreign_key_error trx_adaptive_hash_latched trx_adaptive_hash_timeout

View events that take a long time. Select sysdate (); AM and the start time of the transaction is AM. The display is abnormal. The thread ID (trx_mysql_thread_id) of the transaction ).

Run the following command:

Kill thread ID

The database is restored normally.

View locked transactions

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;

View the transaction waiting for the lock

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;

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.