Considering the fact that HBase stores each column family in a separate HFile and the fact that a row can span many Column Families. How does HBase ensure that a put/delete operation on a row that spans multiple column families is indeed atomic ?
Apache HBase (TM) is not an ACID compliant database.
An HBase table is made of column families which are the logical and physical grouping of columns. The columns in one family are stored separately from the columns in another family. If you have data that is not often queried, assign that data to a separate column family.
Technically, HBase can manage more than three of four column families. However, you need to understand how column families work to make the best use of them.
An HBase column includes two components: a column family and a column qualifier. These components are delimited by a colon : character, <column-family>:<column-qualifier>. An HBase row consists of a row key and one or more column values. A row key is a unique identifier for the table row.
All writes to the a row, no matter how many column families might be in that row, go to one regionserver, and that regionserver then writes the edit to the regions WAL (Hlog), then the writes are sync'd, then the data is added to the memstore so it will be served. Then - once the memstore has hit its limit - the memstore be flushed to disk. If any problems occur to the regionserver and it crashes/dies/has the plug pulled the WAL can be run through to keep everything consistant. For more gory details see the HBASE-2283 and Hbase Architecture 101.
HBase currently achieves row-level atomicity in spite of writing multiple HFiles by flushing all column families at the same time. The flush is triggered when the biggest column family reaches the configured flush size. There is an additional MemStore-level timestamp that allows to do multi-version concurrency control for MemStore reads, but that does not exist for key/values that are written to HFiles. Switching to per-column-family flush (a desirable feature for improving efficiency) would require a similar timestamp to be added to the file format as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With