当前位置:网站首页>[MySQL special] read lock and write lock
[MySQL special] read lock and write lock
2022-07-03 11:59:00 【Programmer Xiao Li】
mysql There are four queues in , Respectively store the information of the current acquisition of read lock 、 Currently obtain the information of write lock 、 Wait for the lock reading message 、 Wait for the message of writing the lock :
| queue | meaning |
| current read-lock queue | Currently acquire read lock queue |
| current write-lock queue | Currently get write lock queue |
| pending read-lock queue | Waiting for lock reading queue |
| pending write-lock queue | Waiting for the write lock queue |

Acquisition conditions of read lock
1. The current resource is not written and the lock is occupied .
2. There is currently no Waiting for the write lock queue There is no high priority write lock waiting in .
If the above conditions are met , The read lock can be obtained directly , If one cannot be satisfied , entering PRQ

Write lock acquisition conditions
1. The current resource is not occupied by write lock .
2. PWQ No waiting to write lock
3. RQ No read lock

lock , It's a computer .
Existing write lock , Repel any lock
as everyone knows , Write lock repels everything , For data security , And the accuracy of data reading , Write lock repels all other forms of lock .
Writing locks is like playing 【 Write 】 The computer game , Others must not play at the same time 【 Write 】 This computer , Want to play 【 Intention to write 】 I can't play . meanwhile , People who play games are also selfish , Afraid of losing and losing face , Don't let others watch 【 read 】, Want to see 【 Intentional reading 】 Don't let me see .

Existing lock reading , Exclude all forms of write lock , Including intentional write lock
When there is a read lock , No more write locks . But concurrent reads are allowed . Although intention lock is a kind of intention , The lock is not in the real sense , But there is also the truth that reading and writing are exclusive .
Reading a lock is like watching it on a computer 【 read 】 The movie , Others must not play at the same time 【 Write 】 The computer game , Want to play 【 Intention to write 】 I can't play . meanwhile , People who watch movies know how to share , Invite others to watch 【 read 】, Want to see 【 Intentional reading 】 Let's see .

When writing lock with existing intention , Exclude all entity locks
Intention writing lock , It means I want to write , The next step is to really get the write lock , Therefore, entity read / write locks will be excluded , But intention is intention after all , No practical significance has been obtained , You can't help but allow others to imagine .
Intentional lock writing is like waiting in line for the computer to play 【 Write 】 game , The next one is you , Waiting in line for so long , Others come to play 【 Write 】 You definitely don't agree with the game , Others come to see 【 read 】 You must not agree to the movie . Someone made a wish :” I hope it's time for me to play games next 【 Intention to write 】“, You say? :” If there is no accident, it will come to me right away , You go on YY Well , Allow you to think “. Someone made a wish :” I hope it's my next movie 【 Intentional reading 】“, You say? :” If there is no accident, it will come to me right away , You go on YY Well , Allow you to think “.

When the existing intention reads the lock , Exclude entity write lock
Intention to write lock is an intention , Intend to read , The next step is to acquire the read lock . This will exclude the actual write lock . As mentioned earlier, concurrent reading is allowed , Therefore, read lock will not be excluded . Intention is intention after all , You can't help but allow others to imagine .
Intentional lock reading is like waiting in line 【 Write 】 The movie , The next one is you , Others come to play 【 Write 】 You definitely don't agree with the game , Others come to see 【 read 】 You readily agree to the movie ( After all, I haven't arrived yet , Besides, he may invite me to watch ). Someone made a wish :” I hope it's time for me to play games next 【 Intention to write 】“, You say? :” If there is no accident, it will come to me right away , You go on YY Well , Allow you to think “. Someone made a wish :” I hope it's my next movie 【 Intentional reading 】“, You say? :” If there is no accident, it will come to me right away , Keep making wishes , Maybe we can watch it together “.

Update Use where When the conditions , Hit index , Lock a line , Row write lock use

Update Use where When the conditions , No hit index , Lock table

update Use where When the conditions , Hit index , But the scope of use , Locking clearance
update Use where Conditions , Some conditions use indexes , Lock all data rows covered by this index , Data row lock
Both transactions operate on two tables , Acquire different locks successively , Lead to a deadlock
边栏推荐
- STL教程8-map
- Vulnhub's Tomato (tomato)
- 安裝electron失敗的解决辦法
- Optimize interface performance
- STL tutorial 8-map
- 2022年中南大学夏令营面试经验
- vulnhub之Ripper
- 《剑指offer 03》数组中重复的数字
- MCDF Experiment 1
- Xiaopeng P7 hit the guardrail and the airbag did not pop up. The official responded that the impact strength did not meet the ejection requirements
猜你喜欢

Groovy test class and JUnit test

Duplicate numbers in the array of sword finger offer 03

win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法

(数据库提权——Redis)Redis未授权访问漏洞总结

After watching the video, AI model learned to play my world: cutting trees, making boxes, making stone picks, everything is good

The excel table is transferred to word, and the table does not exceed the edge paper range

Why can't my MySQL container start

MCDF实验1

vulnhub之Ripper

Vulnhub's cereal
随机推荐
剑指offer专项32-96题做题笔记
Solution à la défaillance de l'installation d'Electron
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据、在折线移动方向添加数据点
Xml的(DTD,xml解析,xml建模)
Quantitative calculation research
Test classification in openstack
MySQL uses the method of updating linked tables with update
Sheet1$.输出[Excel 源输出].列[XXX] 出错。返回的列状态是:“文本被截断,或者一个或多个字符在目标代码页中没有匹配项。”。
libvirt 中体验容器
安裝electron失敗的解决辦法
Excel快速跨表复制粘贴
STL tutorial 8-map
R language uses grid of gridextra package The array function combines multiple visual images of the ggplot2 package horizontally, and the ncol parameter defines the number of columns of the combined g
ArcGIS application (XXI) ArcMap method of deleting layer specified features
Notes on 32-96 questions of sword finger offer
Kubernetes three dozen probes and probe mode
Wrong arrangement (lottery, email)
The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.
在CoreOS下部署WordPress实例教程
CGroup introduction