In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail about the deadlock in mysql and its solutions. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
What's a deadlock?
The so-called deadlock: refers to two or more processes in the implementation process, caused by the competition for resources caused by a mutual waiting phenomenon, if there is no external force, they will not be able to move forward. At this point, it is said that the system is in a deadlock state or the system has a deadlock, and these processes that are always waiting for each other are called deadlock processes. Because the occupation of resources is mutually exclusive, when a process applies for resources, the process can never allocate the necessary resources and can not continue to run without external assistance, which leads to a special phenomenon deadlock. A situation in which two or more threads in the executing program are permanently blocked (waiting), and each thread is waiting for resources that are occupied and blocked by other threads.
The cause of the deadlock:
(1) lack of system resources.
(2) the order in which the process runs and advances is not appropriate.
(3) improper allocation of resources.
If the system resources are sufficient and the resource requests of the process can be met, the possibility of deadlock is very low, otherwise it will fall into a deadlock because of competing for limited resources. Secondly, the process runs in different order and speed, which may also lead to deadlock.
Four necessary conditions for creating a deadlock:
(1) Mutual exclusion condition: a resource can only be used by one process at a time.
(2) request and retention conditions: when a process is blocked by a request for resources, it holds on to the resources it has acquired.
(III) non-deprivation conditions: resources that have been acquired by the process cannot be forcibly deprived until they have been used up.
(4) cyclic waiting condition: a circular waiting resource relationship is formed between several processes.
These four conditions are the necessary conditions of deadlock, as long as deadlock occurs in the system, these conditions must be established, and as long as one of the above conditions is not met, deadlock will not occur.
Detect deadlock
The database system implements a variety of deadlock detection and deadlock timeout mechanisms. The InnoDB storage engine can detect the circular dependency of a deadlock and immediately return an error.
Deadlock recovery
After a deadlock occurs, the deadlock can be broken only if one of the transactions is partially or completely rolled back.
InnoDB currently handles deadlocks by rolling back transactions that hold the least row-level exclusive locks. Therefore, transactional applications must be designed to consider how to handle deadlocks, and in most cases only transactions that are rolled back due to deadlocks need to be re-executed.
About the deadlock in mysql to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.