HBase Transaction)

Source: Internet
Author: User
WhatisTransaction: Atransactioncomprisesaunitofworkperformedwithi

What is Transaction first extract A Wiki definition of Transaction (transaction): a Transaction comprises A unit of work completed MED withi

What is Transaction

First, extract a Wiki definition of Transaction (Transaction:

A transaction comprises a unit of work performed med within a database management system (or similar system) against a database, and treated in a coherent and reliable way independent of other transactions. transactions in a database environment have two main purposes:
1. to provide reliable units of work that allow correct recovery from failures and keep a database consistent even in cases of system failure, when execution stops (completely or partially) and repeated operations upon a database remain uncompleted, with unclear status.

2. To provide isolation between programs accessing a database concurrently. If this isolation is not provided, the program's outcome are possibly erroneous.
A database transaction, by definition, must be atomic, consistent, isolated and durable. Database practitioners often refer to these properties of database transactions using the acronym ACID.
Transactions provide an "all-or-nothing" proposition, stating that each work-unit timed med in a database must either complete in its entirety or have no effect whatsoever. further, the system must isolate each transaction from other transactions, results must conform to existing constraints in the database, and transactions that complete successfully must get written to durable storage.

Among them, all-or-nothing clearly expresses the nature of the transaction: "either completely successful or nothing has happened ". It can be viewed as an atomic operation.

HBase Transaction

(Note: After being supplemented and modified, the description in this blog post is not accurate enough on the first day)

HBase supports a limited number of transactions. There are two new features in HBase 0.94:

[HBASE-3584]-Allow atomic put/delete in one call.

[HBASE-5229]-Provide basic building blocks for "multi-row" local transactions.

Article 1: Interpretation of NoSQLFan:

"Version 0.94 has more complete transaction support: Previously Hbase provided row-level transactions, but each transaction can only execute one write operation, such as a series of Put and Delete operations consecutively, these operations are separate transactions, but they are not performed atomically. In version 0.94, Put and Delete can be performed atomically in the same transaction ."

How to use it? The following Sample is provided:

// Add API for atomic row mutations to HBase (currently Put and Delete ).
Client API wocould look like this:
Delete d = new Delete (ROW );
Put p = new Put (ROW );
//...
AtomicRowMutation arm = new AtomicRowMutation (ROW );
Arm. add (p );
Arm. add (d );
MyHtable. atomicMutation (arm );

We can see that the transaction here is only a series of Put/Delete operations for a row. A series of operations between different rows and tables cannot be placed in one transaction.

Article 2, my personal understanding, this is a multi-line transaction! But it seems to be "multiple rows in the same Region ". Because the phrase "Global (cross region) transactions are not discussed here ."

Therefore, for a multi-Region table, it cannot be ensured that each modification can be encapsulated as a transaction.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.