In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "read-write lock and concurrency control in mysql". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "read-write lock and concurrency control in mysql".
1. Concurrency control problems arise whenever multiple queries modify data at the same time.
two。 This paper discusses how mysql concurrently controls reads and writes at two levels, the server layer and the storage engine layer.
3. Give an example of a mbox mailbox file, saying that if there are multiple processes writing to the mbox file at the same time, then at the end of the file, cross-confusion will be added, such as process 1 wrote several lines, process 2 also wrote several lines, cross each other, the data is wrong. A well-designed mbox needs to be locked, for example, process 1 locks the file, and process 2 must wait for process 1 to finish before the lock is released to write. But in this way, concurrency is not supported. Only one process can write data at a time.
4. There may also be problems when reading. For example, it is not safe when one process is reading data and another process wants to delete data at the same time; the shared lock is called read lock, and the exclusive lock is called write lock.
5. The read lock is shared and does not block other read locks; the write lock is exclusive and it blocks other read and write locks; read is not mutually exclusive, read and write are mutually exclusive
Locking occurs all the time in 6.mysql. When a user is modifying data, it will block other users from reading the data.
There are two lock granularities in 7.mysql, locking the entire table and locking a row in the table
Table lock: when a user modifies data, a write lock is acquired. At this time, the whole table is locked, and no other user can read or write, myisam.
Row lock: when a user modifies certain rows of data, it acquires a write lock, and only locks those rows, which other users cannot read or write; other rows have no impact, but administrative locks consume resources, innodb
8. Use the command to lock the table
Unlock tables unlocks all lines
Lock tables table name read or write
Test read write / write read mutex
1. Add read lock
Reading data will not affect, writing data will be blocked.
two。 Add write lock
Both reading and writing will be blocked
Thank you for reading, the above is the content of "read-write lock and concurrency control in mysql". After the study of this article, I believe you have a deeper understanding of the problem of read-write lock and concurrency control in mysql, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.