HBase has disappearing rows

I guess this may have a place if your application data is transient in nature and doesn’t need to be retained forever.

We first take an existing table and for a given column family set its “time to live” to 30 seconds. According to the documentation, the cell will be removed after this time.

hbase(main):010:0> disable 'myxml'
0 row(s) in 2.0870 seconds

hbase(main):011:0> alter 'myxml', {NAME => 'xmlfamily', TTL => '30'}
0 row(s) in 0.1080 seconds

hbase(main):012:0> enable 'myxml'
0 row(s) in 2.0770 seconds

We then insert a row…

hbase(main):013:0> put 'myxml', '1', 'xmlfamily:mdata_xml', 'foo'
0 row(s) in 1.0980 seconds

…and show that it exists right now…

hbase(main):014:0> scan 'myxml'
ROW                                           COLUMN+CELL
 1                                            column=xmlfamily:mdata_xml, timestamp=1310152994856, value=foo
1 row(s) in 0.2890 seconds

hbase(main):015:0> get 'myxml', '1'
COLUMN                                        CELL
 xmlfamily:mdata_xml                          timestamp=1310152994856, value=foo
1 row(s) in 0.4170 seconds

…but after we wait a minute or so, it is “gone”…

hbase(main):016:0> get 'myxml', '1'
COLUMN                                        CELL
0 row(s) in 0.0490 seconds

hbase(main):017:0>

It should be noted that the default TTL for a column family is 2,147,483,647 seconds, which is roughly 68 years. As such, we should be safe 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.