In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "MySQL deadlock case sharing". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
Two small examples of deadlocks:
Deadlock Case 1
For example, self-increasing deadlocks, general deadlocks are 4 DML statements mutually contained, we can do integration, simplification, so that the deadlock scene becomes complex. Let's do a quick simulation.
create table t8
(c1 int auto_increment,
c2 int default null,
primary key(c1),
unique key (c2)
)ENGINE=InnoDB ;
#session1
Begin;
insert into t8 values(null,10);
#session2
insert into t8 values(null,10);
#session1
insert into t8 values(null,9);
Deadlock Case 2
For example, our difficulty escalation, two delete statements caused by deadlock.
create Table: CREATE TABLE `d` (
`i` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`i`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
insert into d values(1);
##session1
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> select *from d where i=1 lock in share mode;
+---+
| i |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
##session2
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> select *from d where i=1 lock in share mode;
+---+
| i |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
#session1
mysql> delete from d where i=1;
Query OK, 1 row affected (10.80 sec)
##session2
mysql> delete from d where i=1;
ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction
mysql>
"MySQL deadlock case sharing" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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.