By Lars Hofhansl As we know, ACID stands for Atomicity, Consistency, Isolation, and Durability. HBase supports ACID in limited ways, namely Puts to the same row provide all ACID guarantees. (HBASE-3584 adds multi op transactions and HBASE-
By Lars HofhanslAs we know, ACID stands for Atomicity, Consistency, Isolation, and Durability.
HBase supports ACID in limited ways, namely Puts to the same row provide all ACID guarantees. (HBASE-3584 adds multi op transactions and HBASE-5229 adds multi row transactions, but the principle remains the same)
So how does ACID work in HBase?
HBase employs a kind of MVCC. And HBase has no mixed read/write transactions.
The nomenclature in HBase is bit strange for historical reasons. In a nutshell each RegionServer maintains what I will call "strictly monotonically increasing transaction numbers".
When a write transaction (a set of puts or deletes) starts it retrieves the next highest transaction number. In HBase this is called a WriteNumber.
When a read transaction (a Scan or Get) starts it retrieves the transaction number of the last committed transaction. HBase calls this the ReadPoint.
Each created KeyValue is tagged with its transaction's WriteNumber (this tag, for historical reasons, is called the memstore timestamp in HBase. Note that this is separate from the application-visible timestamp.)
The highlevel flow of a write transaction in HBase looks like this:
- lock the row(s), to guard against concurrent writes to the same row(s)
- retrieve the current writenumber
- apply changes to the WAL (Write Ahead Log)
- apply the changes to the Memstore (using the acquired writenumber to tag the KeyValues)
- commit the transaction, i.e. attempt to roll the Readpoint forward to the acquired Writenumber.
- unlock the row(s)
- open the scanner
- get the current readpoint
- filter all scanned KeyValues with memstore timestamp > the readpoint
- close the scanner (this is initiated by the client)
It is important to realize that this only works if transactions are committed strictly serially; otherwise an earlier uncommitted transaction could become visible when one that started later commits first. In HBase transaction are typically short, so this is not a problem.
HBase does exactly that: All transactions are committed serially.
Committing a transaction in HBase means settting the current ReadPoint to the transaction's WriteNumber, and hence make its changes visible to all new Scans.
HBase keeps a list of all unfinished transactions. A transaction's commit is delayed until all prior transactions committed. Note that HBase can still make all changes immediately and concurrently, only the commits are serial.
Since HBase does not guarantee any consistency between regions (and each region is hosted at exactly one RegionServer) all MVCC data structures only need to be kept in memory on every region server.
The next interesting question is what happens during compactions.
In HBase compactions are used to join multiple small store files (create by flushes of the MemStore to disk) into a larger ones and also to remove "garbage" in the process.
Garbage here are KeyValues that either expired due to a column family's TTL or VERSION settings or were marked for deletion. See here and here for more details.
Now imagine a compaction happening while a scanner is still scanning through the KeyValues. It would now be possible see a partial row (see here for how HBase defines a "row") - a row comprised of versions of KeyValues that do not reflect the outcome of any serializable transaction schedule.
The solution in HBase is to keep track of the earliest readpoint used by any open scanner and never collect any KeyValues with a memstore timestamp larger than that readpoint. That logic was - among other enhancements - added with HBASE-2856, which allowed HBase to support ACID guarantees even with concurrent flushes.
HBASE-5569 finally enables the same logic for the delete markers (and hence deleted KeyValues).
Lastly, note that a KeyValue's memstore timestamp can be cleared (set to 0) when it is older than the oldest scanner. I.e. it is known to be visible to every scanner, since all earlier scanner are finished.
Update Thursday, March 22:
A couple of extra points:
- The readpoint is rolled forward even if the transaction failed in order to not stall later transactions that waiting to be committed (since this is all in the same process, that just mean the roll forward happens in a Java finally block).
- When updates are written to the WAL a single record is created for the all changes. There is no separate commit record.
- When a RegionServer crashes, all in flight transaction are eventually replayed on another RegionServer if the WAL record was written completely or discarded otherwise.
原文地址:ACID in HBase, 感谢原作者分享。

随着大数据时代的到来,数据处理和存储变得越来越重要,如何高效地管理和分析大量的数据也成为企业面临的挑战。Hadoop和HBase作为Apache基金会的两个项目,为大数据存储和分析提供了一种解决方案。本文将介绍如何在Beego中使用Hadoop和HBase进行大数据存储和查询。一、Hadoop和HBase简介Hadoop是一个开源的分布式存储和计算系统,它可

PHP编程中的数据严谨性设计(ACID)在PHP编程中,数据的严谨性设计是非常重要的一个方面。一个可靠的应用程序不仅需要正确地处理数据,还需要保证数据的安全性和一致性。为此,开发人员需要使用ACID进行数据设计,以确保系统的稳定性和可靠性。ACID是指原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)和持久性(Dur

依赖:org.springframework.dataspring-data-hadoop-hbase2.5.0.RELEASEorg.apache.hbasehbase-client1.1.2org.springframework.dataspring-data-hadoop2.5.0.RELEASE增加配置官方提供的方式是通过xml方式,简单改写后如下:@ConfigurationpublicclassHBaseConfiguration{@Value("${hbase.zooke

如何使用Java开发一个基于HBase的NoSQL数据库应用引言:随着大数据时代的到来,NoSQL数据库成为处理海量数据的重要工具之一。HBase作为一种开源的分布式NoSQL数据库系统,在大数据领域具有广泛的应用。本文将介绍如何使用Java来开发基于HBase的NoSQL数据库应用,并提供具体的代码示例。一、HBase介绍:HBase是基于Hadoop的分

随着互联网应用和数据量的不断增长,传统的关系型数据库已经不能满足存储和处理海量数据的需求。而NoSQL(NotOnlySQL)作为一种新型的数据库管理系统,其能够在海量数据存储和处理方面具有显著的优势,得到越来越多的关注和应用。在NoSQL数据库中,ApacheHBase是一个非常流行的开源分布式数据库,它基于Google的BigTable思想设计,具

随着大数据时代的到来,海量数据的存储和处理显得尤为重要。在NoSQL数据库方面,HBase是目前广泛应用的一种解决方案。Go语言作为一种静态强类型编程语言,由于其语法简单、性能优秀,被越来越多地应用于云计算、网站开发和数据科学等领域。本文将介绍如何在Go语言中使用HBase来实现高效的NoSQL数据库应用。HBase介绍HBase是一个高可扩展、高可靠性、基

在Beego框架中使用HBase进行数据存储和查询随着互联网时代的不断发展,数据储存和查询变得越来越关键。大数据时代来临,各种数据源都在各自不同的领域占据着重要地位,其中非关系型数据库是一种在数据存储和查询方面优势明显的数据库,而HBase是一种基于Hadoop的分布式非关系型数据库。本文将介绍如何在Beego框架中使用HBase进行数据存储和查询。一、H

Workerman是一款高性能的PHPsocket框架,它的特点是可以承载大量的并发连接。与传统的PHP框架不同的是,Workerman不依赖于Apache或Nginx等Web服务器,而是通过开启一个PHP进程,独自运行整个应用程序。Workerman具有极高的运行效率和更好的负载能力。与此同时,HBase是一个分布式的NoSQL数据库系统,广泛应用于大数


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

WebStorm Mac版
好用的JavaScript开发工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3汉化版
中文版,非常好用

Dreamweaver Mac版
视觉化网页开发工具