In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to use MVCC correctly". 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 how to use MVCC correctly.
Simple understanding version
The following quotes from the article I wrote before can be understood quickly. I suggest you take a brief look at it first.
To talk about phantom reading, the first thing to understand is that MVCC,MVCC is called multi-version concurrency control, which actually saves a snapshot of the data at a node at a certain time.
We actually hide two columns per row of data, the creation time version number, the expiration (delete) time version number, and each time we start a new transaction, the version number is automatically incremented.
Let's take the user table above as an example, suppose we insert two pieces of data, and they should actually look like this.
At this time, suppose Xiaoming executes the query, and at this time current_version=3
Select * from user where idlow_limit,trx_id is still within the [low_limit_id,up_limit_id] range, and if trx_id is in m_ids, it will look up the undo log log chain according to roll_pointer and find the data of the previous version, corresponding to the scenario in which Xiao Ming queries again after Xiao Hong modifies.
If trx_id=creator_trx_id, then the description is modified by yourself, and just return it directly. It corresponds to the scenario in which Xiao Ming modifies the data himself.
Implementation of different isolation levels
Based on the principles described above, you may have found that this is a repeatable implementation to ensure that the data read is consistent each time.
So, if you are reading at the submitted level, how is this achieved?
In fact, it is very simple. In the above explanation of principle, I assume that read view is generated at each query, but not regenerated later.
At the read submitted level, a read view is generated for each query.
Take the above Xiao Hong modified Zhang San scene as an example.
At the repeatability level, because trx_id > low_limit,trx_id is still within the [low_limit_id,up_limit_id] range, and trx_id is in m_ids, which meets our above condition 2, the previous version record will be found according to roll_pointer to ensure repeatability.
At the read committed level, the read view is regenerated. At this time, the trx_id is not in the m_ids, indicating that the transaction has been committed, so you can return this data directly, so the data found is the modified name= Zhang 33 data of Xiao Hong.
Thank you for your reading, the above is the content of "how to use MVCC correctly". After the study of this article, I believe you have a deeper understanding of how to correctly use MVCC, 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: 224
*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.