Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Analysis of MySQL deadlock

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "MySQL deadlock case analysis". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn the "MySQL deadlock case study"!

A preface

Deadlock, in fact, is a very interesting and challenging technical problem, probably every DBA and some developers will encounter in the course of work.

Case study 2.1 Business scenario

Business developers want to synchronize data, their logic is through the update update operation, if the affect_rows returned by the update record is 0, then the insert statement is called for insert initialization. If the insert fails, the update operation is performed, and a deadlock occurs in the case of multiple sessions operating concurrently.

2.2 description of the environment

MySQL 5.6.24 transaction isolation level is RR

Create table ty (id int not null primary key auto_increment, C1 int not null default 0, c2 int not null default 0, c3 int not null default 0, unique key uc1 (C1), unique key uc2 (c2)) engine=innodb; insert into ty (C1 int not null default c2penc 3) values (1meme 3meme 4), (6meme 6pim10), (9pjin14); at this point, I believe you have a deeper understanding of "MySQL deadlock case analysis", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report