hbase-python icon indicating copy to clipboard operation
hbase-python copied to clipboard

hbase.exceptions.RequestError: Failed to get region for default namespace

Open NazariiMed opened this issue 5 years ago • 0 comments

I got hbase.exceptions.RequestError: Failed to get region exception when tried to do get operation from the table located in the default namespace.

Here is my code:

    with hbase.ConnectionPool(zk).connect() as conn:
        table = conn['default']['table_name']
        row = table.get('row1')
        print(row)
    exit()

Traceback (most recent call last): File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1664, in main() File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1658, in main globals = debugger.run(setup['file'], None, None, is_module) File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1068, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/Users/nazarii/PycharmProjects/smartness/scripts/hbase/hbase_test.py", line 25, in main() File "/Users/nazarii/PycharmProjects/smartness/scripts/hbase/hbase_test.py", line 17, in main row = table.get('ts/github/82270896/1487289600000') File "/Users/nazarii/PycharmProjects/untitled/venv/lib/python3.7/site-packages/hbase/table.py", line 117, in get return self._client.get(self.full_name, key, columns, filter) File "/Users/nazarii/PycharmProjects/untitled/venv/lib/python3.7/site-packages/hbase/client/client.py", line 753, in get region = self._region_manager.get_region(table, key) File "/Users/nazarii/PycharmProjects/untitled/venv/lib/python3.7/site-packages/hbase/client/region.py", line 202, in get_region 'Failed to get region.' hbase.exceptions.RequestError: Failed to get region.

I did further investigation and find the reason.

When this function is called https://github.com/3601314/hbase-python/blob/4230091664730908f8e90a057b310f10ffb73ad1/hbase/client/region.py#L247

We have meta_key = 'default:table_name,row1,:' Change that to the meta_key = 'table_name,row1,:' fixes the issue.

So HBase API does expect only table_name for the default namespace and default:table_name is not valid.

I would suggest fixing that. I can do that myself and open PR if you agree to change the way the meta_key is formed.

NazariiMed avatar Apr 22 '19 12:04 NazariiMed