当前位置:网站首页>The essence of transaction and the principle of deadlock
The essence of transaction and the principle of deadlock
2020-11-06 21:35:00 【Irving the procedural ape】
Only with MySQL and spring For example ,, This article does not introduce the concepts of transactions and locks .
This paper uses pseudo code to represent method code , Only express the meaning of the method and transaction annotation
〇、 The shape of the transaction
In my heart , Business has always been like this 
x Axis is a locked resource ,y The axis is the time consumed ,
The transaction box moves down over time ,
When touching x Lock the shaft , Skip over x When the axis is unlocked
The picture above is about the method a The transaction shape of , I named it 【 Transaction box 】, I'm sorry I don't know how to do motion maps , In this paper, we express the best by moving graph .
@Transactional function a(){
Yes A Table modification , It took five seconds }
One 、 A lot of business
When a method calls multiple child methods annotated by a transaction, the situation is 
The picture above is about the method abc Invocation time ,a Method 、b Method 、c The transaction shape of the method function abc(){
this.a(){}
this.c(){}}@Transactional function a(){
Yes A Table modification , It took five seconds }@Transactional function b(){
Yes B Table modification , It took five seconds }@Transactional function c(){
Yes C Table modification , It took five seconds }
among abc When the method starts to execute , Execute to a Method , lock a surface , When a Method end b At the beginning of the method ,a Table unlocking ,b Table locking , When b Method end c At the beginning of the method ,b Table unlocking c Table locking .
It is equivalent to that the three transaction blocks in the figure below are united and locked together , Total operation time 15 second 
If concurrent requests are made twice abc Method, the transaction box is shown in the figure below 
among a The watch will be asked first 1 lock 5 Seconds later to unlock , Be asked again 2 lock 5 second ,
among b The watch will also be requested first 1 lock 5 Seconds later to unlock , Be asked again 2 lock 5 second ,
among c The watch will also be requested first 1 lock 5 Seconds later to unlock , Be asked again 2 lock 5 second ,
The request 1 In the unlock table a And then it locked the watch b Five seconds , At the same time a Be asked again 2 lock 5 second
By analogy , request 2 All asking for 1 After unlocking the corresponding table , Lock the table ,
So the total running time 20 second
Two 、 Large transactions @Transactional function abc(){
this.a(){}
this.b(){}
this.c(){}}
funct.........
版权声明
本文为[Irving the procedural ape]所创,转载请带上原文链接,感谢
边栏推荐
- Some operations kept in mind by the front end foundation GitHub warehouse management
- Visual rolling [contrast beauty]
- From overseas to China, rancher wants to do research on container cloud market
- 【涂鸦物联网足迹】涂鸦云平台全景介绍
- The isolation level of transaction and its problems
- How to manage the authority of database account?
- list转换map(根据key来拆分list,相同key的value为一个list)
- 细数软件工程----各阶段必不可少的那些图
- Will blockchain be the antidote to the global epidemic accelerating the transformation of Internet enterprises?
- window系统 本机查找端口号占用方法
猜你喜欢

The legality of IPFs / filecoin: protecting personal privacy from disclosure

统计项目代码行数

预留电池接口,内置充放电电路及电量计,迅为助力轻松搞定手持应用

Multi robot market share solution

Elasticsearch database | elasticsearch-7.5.0 application construction
![[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!](/img/3b/00bc81122d330c9d59909994e61027.jpg)
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!

Road to simple HTML + JS to achieve the most simple game Tetris

What is alicloud's experience of sweeping goods for 100 yuan?

Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)

ES6 learning notes (5): easy to understand ES6's built-in extension objects
随机推荐
Metersphere developer's Manual
Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)
mongo 用户权限 登录指令
2020-08-14:数据任务的执行引擎用的哪些?
Tron smart wallet PHP development kit [zero TRX collection]
Try to build my mall from scratch (2): use JWT to protect our information security and perfect swagger configuration
2020-08-17:详细说下数据倾斜怎么解决?
ES6 learning notes (2): teach you to play with class inheritance and class objects
Vue communication and cross component listening state Vue communication
Kubernetes and OAM to build a unified, standardized application management platform knowledge! (Internet disk link attached)
Elasticsearch database | elasticsearch-7.5.0 application construction
轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
Git rebase is in trouble. What to do? Waiting line
How about small and medium-sized enterprises choose shared office?
Summary of front-end performance optimization that every front-end engineer should understand:
意外的元素..所需元素..
Novice guidance and event management system in game development
(2) ASP.NET Core3.1 Ocelot routing
What grammar is it? ]
What is the tensor in tensorflow?