当前位置:网站首页>Summary of database Deadlock: (3.7-3.13)
Summary of database Deadlock: (3.7-3.13)
2022-04-22 05:16:00 【Look, water is water】
brief introduction :
Database deadlock is generally a state of waiting for deadlock caused by two or more threads competing for a resource at the same time , For example, user access thread A Lock the record C, Another user accesses the thread B And need
Access records C It will form a deadlock ;
The main cause of deadlock :
1. Insufficient system resources ;( Deadlock is rarely formed when system resources are fully allocated )
2. The order of objects accessed is inconsistent ;
3. Improper allocation of system resources, etc ;
Four necessary conditions for deadlock ( Be short of one cannot ):
1. mutual exclusion : At the same time , An object resource can only be used by one thread , Other threads cannot occupy ;
2. Request and hold conditions : When a process initiates an access request for a new resource , The resources held by itself will not be released ;
3. Conditions of non deprivation : When the resources of a process are not used up , Can't be forcibly deprived of ;
4. Loop wait condition : Two or more processes form the condition of waiting for the same resource in the first place ;
Measures to reduce deadlocks :
1. Multiple threads access objects sequentially at the same time : Between multiple threads , Like threads A And thread B All need to access the table A And table B, Threads A First access the table A Revisit table B, In this process, the thread B In a waiting state ;
2. Avoid user interaction : On the ground , The efficiency of transactions without user interaction is much higher than that with user interaction , If there is a scene of user interaction , When the user needs to enter a string of authentication or other content , This
When , Users don't do anything else in front of the computer , It will cause a blocking waiting state of resources , Slightly worse performance , In severe cases, access to this resource by other threads will cause deadlock ;
3. Multiple transactions should be as short as possible and in a batch : Because if there are more than one chief of staff , The exclusive lock or update lock held by itself takes a long time , Easy to deadlock , So try to keep things short , Multiple
Try to process transactions in a batch transaction , Because the fewer transactions , The less network performance overhead , Faster performance response , Causing a delay in the completion of a transaction
The less likely it is ;
4. Use low isolation levels : In some scenes , We can use a lower level of isolation on the premise of completing the task , For example, the level of serialization can be changed to the level of read commit to complete transactions ;
5. Binding connection : When an application binds two or more connections , The lock resource used by the secondary connection can be held like the lock held by the primary connection , There is no deadlock risk , contrary
It's the same thing ;
版权声明
本文为[Look, water is water]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210626122042.html
边栏推荐
- VIM is so difficult to use, why are so many people keen?
- What are the challenges of Internet of things testing, and how do software testing institutions ensure quality
- Pydeck enables efficient visual rendering of millions of data points
- Nexus private server - (II) console installation of version 3.2.0, initial password location
- Learn from me: how to release your own plugin or package in China
- Reading: analyzing third party service dependencies in modern web services
- Common test methods
- Measuring the global recursive DNS infrastructure: a view from the edge
- The problem that the video in video becomes muted when the mouse scrolls
- Basic concepts of outh2
猜你喜欢

Pytorch builds a two-way LSTM to realize time series forecasting (load forecasting)

13.9.1-PointersOnC-20220421

Leetcode 1557. Minimum number of vertices to reach all nodes

Chapter IV constraints and indexes

abcabc

Chapter VIII affairs

Domain name encryption is not enough: privacy leakage via IP based website fingerprinting

Spark 入門程序 : WordCount

Chapter V function

Spark starter: wordcount
随机推荐
How to modify the IP address of the rancher server
Regular expression validation
Reading: analyzing third party service dependencies in modern web services
Summary of common methods, advantages and disadvantages of robot UAV visual obstacle avoidance
Leetcode 1387. Sort integers by the power value
What are the challenges of Internet of things testing, and how do software testing institutions ensure quality
Does lvgl really need to write code for each control? Don't be naive. When you know the principle, let's drag the control~
Junit常用注解
What is idempotency
Restful style API design
Common test methods
什么是幂等性
Summary of browser cross domain problems
Introduction to swagger UI
【Pytorch】Tensor. Use and understanding of continguous()
防抖函数和节流函数
Paper reading - access pattern disclosure on searchable encryption: allocation, attack and deviation (2012)
Supplement to the usage of permute() function in torch (detailed process of matrix dimension change)
Detailed explanation of Neptune w800 lighting (interruption) project
Mongodb experiment -- data backup and recovery and database optimization