MySQL in two tables updated when the wonderful problem produced, resulting in deadlocks!

Source: Internet
Author: User

such as the next two table update statements

UPDATE hzxm201610 a,xmhzylb1201610 b SET a.gk07_1_6=b.gk04_11,a.gk07_2_6=b.f06_1,a.gk07_3_6=b.f07_1,a.gk07_4_6= B.f08_1 where substring (a.gk01,1,4) in (' 5323 ') and a.gk01=b.gk01 and dqdm= ' 532300 '

What happens if you miss the Where:

UPDATE hzxm201610 a,xmhzylb1201610 b SET a.gk07_1_6=b.gk04_11,a.gk07_2_6=b.f06_1,a.gk07_3_6=b.f07_1,a.gk07_4_6= B.f08_1 substring (a.gk01,1,4) in (' 5323 ') and a.gk01=b.gk01 and dqdm= ' 532300 '

Generally think that will be error. In fact, this statement is normal execution! And a full scan of two tables, and do nothing at the end! However, it will lock two tables for a long time, causing the application to not work!

Query the MySQL deadlock statement:

#Show processlist;
SELECT * from INFORMATION_SCHEMA. Innodb_trx;
SELECT * from INFORMATION_SCHEMA. Innodb_locks;
SELECT * from INFORMATION_SCHEMA. Innodb_lock_waits;
SHOW VARIABLES like '%lock% ';

MySQL in two tables updated when the wonderful problem produced, resulting in deadlocks!

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.