Skip to content

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

@NazariiMed

Description

@NazariiMed

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

def _region_lookup(self, meta_key):

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions