Get the App
SLTechnology News&Howtos  ›  Database  › 

Case Analysis of MySQL deadlock

Shulou Source: shulou.com Published: 2022-05-31 14:27:06 10月01日 Update

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!

Tags: Deadlocks cases case studies analysis updates business content classmates learning development practical deeper interesting transactions interests prefaces scenarios multiple practical practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Docker Linux Microsoft Huawei