当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- jenkins安装部署过程简记
- How to start the hidden preferences in coda 2 on the terminal?
- In depth to uncover the bottom layer of garbage collection, this time let you understand her thoroughly
- Visual rolling [contrast beauty]
- Axios learning notes (2): easy to understand the use of XHR and how to package simple Axios
- 意派Epub360丨你想要的H5模板都在这里,电子书、大转盘、红包雨、问卷调查……
- Summary of front-end performance optimization that every front-end engineer should understand:
- Zero basis to build a web search engine of its own
- 打工人好物——磨炼钢铁意志就要这样高效的电脑
- 递归、回溯算法常用数学基础公式
猜你喜欢
This project allows you to quickly learn about a programming language in a few minutes
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
Summary of common SQL statements
统计项目代码行数
迅为-iMX6ULL开发板上配置AP热点
STM32F030K6T6兼容替换灵动MM32F031K6T6
2020-08-24:什么是小文件?很多小文件会有什么问题?很多小文件怎么解决?(大数据)
消防器材RFID固定资产管理系统
ES6 learning notes (2): teach you to play with class inheritance and class objects
ES6 learning notes (5): easy to understand ES6's built-in extension objects
随机推荐
Summary of front-end performance optimization that every front-end engineer should understand:
Vue communication and cross component listening state Vue communication
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:曾文旌
What grammar is it? ]
Application insights application insights use application maps to build request link views
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
CCR coin frying robot: the boss of bitcoin digital currency, what you have to know
image operating system windows cannot be used on this platform
上海巨微专用蓝牙广播芯片
Common syntax corresponding table of mongodb and SQL
jenkins安装部署过程简记
ES6 learning notes (4): easy to understand the new grammar of ES6
All the way, I was forced to talk about C code debugging skills and remote debugging
2020-09-09:裸写算法:两个线程轮流打印数字1-100。
es创建新的索引库并拷贝旧的索引库 实践亲测有效!
Why is quicksort so fast?
Summary of front-end interview questions (C, s, s) that front-end engineers need to understand (2)
A small goal in 2019 to become a blog expert of CSDN
Using iceberg on kubernetes to create a new generation of cloud original data Lake
How much disk space does a file of 1 byte actually occupy