In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "mysql innodb line lock example analysis", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "mysql innodb row lock example analysis"!
The real decision on whether to execute the row to be locked is not the row taken out, but the row that is scanned.
Whether the scan record is most indexed or not has something to do with the specific implementation plan.
So when analyzing the lock problem, don't forget to look at the implementation plan.
Session 1: since name is of type varchar, there is an implicit conversion, so all records are scanned and locked.
Root@sakila 10:33:04 > explain select * from tab_no_index where name=1 for update
+-- +
| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+-- +
| | 1 | SIMPLE | tab_no_index | ALL | name | NULL | NULL | NULL | 6 | Using where |
+-- +
1 row in set (0.00 sec)
Root@sakila 10:34:30 > select * from tab_no_index where name=1 for update
+-+ +
| | id | name |
+-+ +
| | 1 | 1 |
+-+ +
1 row in set (0.00 sec)
Session 2: even if the updated record is different from the record selected by answer 1, the update lock cannot be applied because the record was scanned by the first session and locked.
Root@sakila 10:34:35 > select * from tab_no_index where name='4' for update
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
Thank you for your reading, the above is the "mysql innodb row lock example analysis" content, after the study of this article, I believe you have a deeper understanding of the mysql innodb line lock example analysis of this problem, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.