In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How to solve the problem of phantom reading in MySQL? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1. MVCC snapshot, which stores a snapshot of historical data and ensures that it is invisible to the current transaction when the data is added or deleted.
Most databases implement multi-version concurrency control, and all of them rely on saving data snapshots.
In InnoDB, for example, there are two redundant word breaks in each line. One is the created version of the line, and the other is the deleted (expired) version of the line. The version number increases with each transaction. Each time a transaction fetches data, it fetches data with a created version smaller than the current transaction version, and data with an expired version greater than the current version.
Ordinary select is snapshot reading.
Select * from T where number = 1
2. "next-key" lock, which locks the gap between the current data row and the previous data and the next data to ensure that the data read in this range is consistent.
The next-key lock consists of two parts
Record lock (row lock)
Gap lock
A record lock is a lock added to an index, and a gap lock is added between indexes. (think: what happens if there is no index on the column? )
Select * from T where number = 1 for update;select * from T where number = 1 lock in share mode;insertupdatedelete
After reading this article, can you solve the problem of MySQL phantom reading independently? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.
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.