Tuesday, December 13, 2016

HBASE: Table already exists

HBASE: Table already exists


Last weekend while expermenting on Hbase component of Hadoop ecosystem; and i came across an issue while creating table.

=> Hbase::Table - emp
hbase(main):003:0> create 'emp', 'personal data', 'professional data'

ERROR: Table already exists: emp!

Cool so table is already present; that’s ok; might be it is already present; sounds easy peasy right but somehow it turned out to be very interesting for me.

At first i checked its existence and i listed all the table and unfortunately it’s not there.

hbase(main):004:0> list
TABLE
emp_v
random_test
temp_test

So to outsmart Hbase:) i tried deletion

hbase(main):005:0> drop 'emp'

ERROR: Table emp does not exist.

Excellent so in one context Hbase table is not present but it is present sounds whacky right; but all in all its good there is something for me to dig in and there is a saying "They Say Half Knowledge is a Dangerous thing"; so why not add another half and make it full.

I went ahead and tried to see if there is any trace of a file which might left behind and from that Hbase might be reading.

I checked that and I saw only one namespace i.e. "default"


#hdfs dfs -ls /hbase/data

drwxr-xr-x   - hbase hbase          0 2016-12-11 20:51 /hbase/data/default

you can see nowhere a single directory.


# hdfs dfs -ls /hbase/data/default

drwxr-xr-x   - hbase hbase          0 2016-12-08 18:20 /hbase/data/default/emp_v
drwxr-xr-x   - hbase hbase          0 2016-12-09 13:45 /hbase/data/default/random_test
drwxr-xr-x   - hbase hbase          0 2016-12-09 00:08 /hbase/data/default/temp_test


So above didn’t helped either; but this is true that Hbase is reading it from somewhere but where; i started from basics that how client coordinate with Hbase and this proved to be fruitful step for me.

Way forward was "The Zookeeper".

A distributed HBase relies completely on Zookeeper (for cluster configuration and management). In HBase, Zookeeper coordinates, communicates, and shares state between the Masters and Region Servers.

Zookeeper is a client/server system for distributed coordination that exposes an interface similar to a filesystem, where each node (called a Znode) may contain data and a set of children. 

Each Znode has a name and can be identified using a filesystem-like path (for example, /root-znode/sub-znode/my-znode).

Znode which seems to be important for this context 

Znode
Description
hbase/table (zookeeper.znode.masterTableEnableDisable)
Used by the master to track the table state during assignments (disabling/enabling states, for example).



Zookeeper can be accessed via zkcli and i logged in to zookeeper client via hbase zkcli or you may use zookeeper-client command.

i did ls command and issue seems cracked; here is the bright and shiny emp table.

ls /hbase/table
[ random_test, emp,  hbase:meta,  hbase:namespace, temp_test, emp_v] 

As I mentioned above as part of Znode that HBase stores some data schema and state of each table in zookeeper to be able to coordinate between all the region servers .
You might be wondering why table metadata still present although dropped from Hbase??
What is the solution??
Since it seems an orphan kind of table to me; so why not remove the metadata from zookeeper; Zookeeper provides rmr command to remove a specified Znode.
So from same login  I executed below command which expected to remove a Znode i.e. <Metadata of emp table>

rmr /hbase/emp  

and I checked ls command again that whether emp table is still present or not; finally table is removed a big relief to me.

ls /hbase/table
[ random_test,  hbase:meta,  hbase:namespace, temp_test, emp_v] 

And I created table again and this time I succeeded J

hbase(main):001:0>  create 'emp', 'personal data', 'professional data'
0 row(s) in 2.5890 seconds

=> Hbase::Table - emp