HBaseCon 2012 | Relaxed Transactions for HBase - Francis Liu, Yahoo!

Post on 25-May-2015

1397 Views

Category:

Business

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

For Map/Reduce programmers used to HDFS, the mutability of HBase tables poses new challenges: Data can change over the duration of a job, multiple jobs can write concurrently, writes are effective immediately, and it is not trivial to clean up partial writes. Revision Manager introduces atomic commits and point-in-time consistent snapshots over a table, guaranteeing repeatable reads and protection from partial writes. Revision Manager is optimized for a relatively small number of concurrent write jobs, which is typical within Hadoop clusters. This session will discuss the implementation of Revision Manager using ZooKeeper and coprocessors, and paying extra care to ensure security in multi-tenant clusters. Revision Manager is available as part of the HBase storage handler in HCatalog, but can easily be used stand-alone with little coding effort.

Transcript

Relaxed Transactions for HBaseFrancis Liu, Software Engineer

5/22/12

Mutable Data

Writes are effective immediately

Mutable Data

Writes are effective immediately

Mutable Data

Partial writes in the midst of failures

Mutable Data

Partial writes in the midst of failures

Revision Manager

Optimized for batch processing› Large number of writes (ie Data Ingestion, Batch

updates)

Cross row write transactions within a table Coprocessor Endpoint› Leverage HBase Security

Zookeeper for persistence› table revision information

Experimental feature in Hcatalog 0.4

Architecture

API

For reads› RevisionManager.createSnapshot(tableName)› SnapshotFilter.filter(result)

For writes› RevisionManager.beginWriteTransaction(table, families)› RevisionManager.commitWriteTransaction(transaction)› RevisionManager.abortWriteTransaction(transaction)

Concepts

Revision› Monotonically increasing number› All “Puts” of a job are written with the same revision number as the cell

version

TableSnapshot› Point-in-time consistent view of a table› Used for reading› Latest committed revision› List of aborted revisions› Upper bound on visible revision per CF

Transaction› Write transaction› Revision Number› List of column Families being written to

Relaxed Transaction Properties

Immutable Input Change After Commit Precedence Preservation

Immutable Input

Change After Commit

Revisions are only viewable after commit› A job cannot see it’s own writes

Aborted revisions are added to a table’s aborted list

Timed out revisions are aborted

Change After Commit

Precedence Preservation

Snapshot Isolation› Transaction is aborted when a write conflict is detected

Conflicts› Concurrent transactions to the same Column Family › Inefficient to abort

Resolved during read time• For every CF– find: min_rev = min(active_revision)– Only return closest revision to min_rev

• min_rev is what’s stored in a snapshot

Precedence Preservation

Snapshot Filter

Consumes TableSnapshot Read time filtering› Aborted revisions› Revisions written after snapshot was taken› Conflicting/Blocked revisions

Flow - Read

User/Client› RevisionManager.createSnapshot()

• TableSnapshot instance is serialized into JobConf

RecordReader› Using SnapshotFilter.filter(result)

Flow - Read

Flow - Write

User/Client› HBaseOutputFormat.checkOutputSpecs(FileSystem, JobConf)

• Write transaction is started by calling beginWriteTransaction(Transaction)

• Transaction instance is serialized into JobConf

RecordWriter› Puts make use of the revision number as the version

OutputCommitter› OutputCommitter.commitJob(JobContext)

• RevisionManager.commitWriteTransaction(Transaction)

› OutputCommitter.abortJob(JobContext)

• RevisionManager.abortWriteTransaction(Transaction)

Usage

Using HCatalog Revision Manager usage is done under the covers.

Work is being done to decouple HCatalog from HBaseInputFormat/HBaseOutputFormat

Other frameworks can make use of the RevisionManager API

Usage: HCatalog

Create Table

hcat –e “create table my_table(key string, gpa string) STORED BY 'org.apache.hcatalog.hbase.HBaseHCatStorageHandler' TBLPROPERTIES ('hbase.columns.mapping'=':key,info:gpa');”

Using Pig

A = LOAD ‘table1’ USING org.apache.hcatalog.pig.HCatLoader();

STORE A INTO ‘table1’ USING org.apache.hcatalog.pig.HCatStorer();

Using MapReduce

HCatInputFormat.setInput(job,…)

HCatOutputFormat.setOutput(job,…)

Future Work

Compaction of aborted transactions Server-side filtering using HBase Filters Compatibility with Hive

Further Info

hcatalog-user@incubator.apache.org http://incubator.apache.org/hcatalog/ toffer@apache.org

Questions?

top related