In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 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.
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.