In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail the example analysis of row locks and multi-version concurrency control in hbase. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.
MVCC (Multiversion Conversion Control), namely Multiversion concurrency control technology, makes most transaction engines supporting row locks not only use row locks to control concurrency of database, but combine row locks with multiple versions of rows of database, which only needs a small overhead to realize unlocked reads, thus greatly improving the concurrency performance of database system.
HBase ensures efficient concurrent reads and writes through row lock +MVCC.
Why Concurrency Control is Needed
The HBase system itself can only guarantee a single line of ACID properties. ACID means:
atomicity
consistency (Consistency)
Isolation
Durability
Traditional relational databases typically provide ACID across all data; for performance reasons, HBase provides only single-row-based ACID.
Here is an example of hbase concurrent writing.
The raw data are as follows
From Apache HBase Write Path, you can see that hbase writes data in two steps:
1. Write Write-Ahead-Log(WAL) file
2. Write MemStore: Write the data of each cell[(row,column) pair] to memstore in memory
Write synchronous
Assuming no concurrency control on writes, consider the following order:
This gives inconsistent results. Obviously we need to synchronize concurrent writes.
The simplest way to do this is to provide a row-based exclusive lock that guarantees independence from writing to the same row. So the order of writing is:
(0)Get row lock
(1)Write WAL files
(2)Update MemStore: Write each cell to memstore
(3)Release row lock
read-write synchronization
Although locks are placed on concurrent writes, what about reads? See the following examples:
You need concurrency control for reads and writes, otherwise you will get inconsistent data. The simplest solution is to share a lock for reading and writing. Although this guarantees ACID characteristics, read and write operations simultaneously preempt locks will affect each other's performance.
MVCC algorithm
HBase uses MVCC algorithm to avoid read operations to acquire row locks.
For write operations:
(w1)Once the row lock is acquired, each write operation is assigned a write sequence number immediately
(w2)Write operations are carried with write serial numbers when saving each data cell
(w3)The write operation needs to be declared to complete the write operation with this write sequence number
For read operations:
(r1)Each read operation begins with a read sequence number, also known as a read point
(r2)The value of the read point is the largest integer of all write completion numbers (all write completion numbers
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.