Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'mutateRows' #3

Closed
itayB opened this issue Apr 22, 2021 · 9 comments
Closed

AttributeError: 'NoneType' object has no attribute 'mutateRows' #3

itayB opened this issue Apr 22, 2021 · 9 comments

Comments

@itayB
Copy link

itayB commented Apr 22, 2021

I'm trying to use aiohappybase with our old HBase 0.94 :(

Here is my code:

connection = Connection(host="localhost", port=9091, compat="0.94")
table = connection.table(TABLE_NAME)
batch = table.batch()
await batch.counter_inc(day_key, qualifier, value=value)
await batch.counter_inc(month_key, qualifier, value=value)
await batch.send()

and I'm getting an exception on the 3rd row: batch = table.batch():

Traceback (most recent call last):
  File "/indexer/sink.py", line 39, in <module>
    loop.run_until_complete(write_to_hbase([]))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/indexer/sink.py", line 23, in write_to_hbase
    batch = table.batch()
  File "/indexer/venv/lib/python3.8/site-packages/aiohappybase/table.py", line 569, in batch
    return Batch(table=self, **kwargs)
  File "/indexer/venv/lib/python3.8/site-packages/aiohappybase/batch.py", line 304, in __init__
    self._mutations = MutationBatcher(table, timestamp, batch_size, wal)
  File "/indexer/venv/lib/python3.8/site-packages/aiohappybase/batch.py", line 99, in __init__
    mut_rows = self._table.client.mutateRows
AttributeError: 'NoneType' object has no attribute 'mutateRows'

What am I missing here?

UPDATE:
I've found that it is broken in both v1.4.0 + v1.3.0 but it DOES work in v1.2.0.
On the other hand, seems like v1.2.0 doesn't support counter_inc :(

@itayB
Copy link
Author

itayB commented Apr 22, 2021

found it. I had to add:

await connection.open()

after my first row :)

@aiudirog
Copy link
Member

Good catch, I'll see about making the client value an object which raises an error instead of it being None.

@itayB
Copy link
Author

itayB commented Apr 25, 2021

It still doesn't work :(
I'm getting the following exception:

thriftpy2.thrift.TApplicationException: <exception str() failed>

Trying to add a breakpoint and I see:

TApplicationException(type=1, message=b"Invalid method name: 'incrementRows'")

image

my HBase thrift runs with:

hbase-daemon.sh start thrift2 -p 9091

what am I missing now?

@aiudirog
Copy link
Member

aiudirog commented Apr 25, 2021

My guess is that mutateRows incrementRows isn't available in HBase 0.94. I'll dig into this when I get a chance.

Edit: the 0.94 branch shows that it should be there. I'll see if I can set up a test environment and try it out.

@itayB
Copy link
Author

itayB commented Apr 26, 2021

thanks, @aiudirog.
Actually, I've tried several functions (put, get tables, inc) and none of them work.
I've reproduced it locally with HBase in docker (and in my real HBase cluster)

from aiohappybase import Connection


async def main():
    connection = Connection(host="localhost", port=9091, timeout=10_000, compat="0.94")
    await connection.open()
    tables = await connection.tables()
    print(tables)
    connection.close()


loop = asyncio.get_event_loop()
loop.run_until_complete(main())

I also tried to run with the regular package (happybase) and got the same error :(

@itayB
Copy link
Author

itayB commented Apr 26, 2021

I think that I found the issue after trying to contribute here. I ran thrift2 by:

hbase-daemon.sh start thrift2 -p 9090

After changing it to thrift (1) the code above is working:

hbase-daemon.sh start thrift -p 9090

Isn't thrift2 newer? is there support for thrift2? (our production HBase cluster expose Thrift2)

@aiudirog
Copy link
Member

Aha I completely missed that you are using the thrift2 API. Yes that is currently unsupported as this codebase isn't much different than the original happybase.

I think you may be the first to actually require using it and it would be really useful to get the support included. It is probably going to be a lot of work as I recall the API being quite different.

@aiudirog
Copy link
Member

While I don't use the thrift2 API at work, I would like to get it integrated. I've started a new branch on my fork here for any work: https://github.com/aiudirog/aiohappybase/tree/thrift2

The API is different enough that I think it warrants to separate implementations, but I'll have to explore it a bit before I'm 100% sure.

@aiudirog
Copy link
Member

I'm going to close this in favor of having two dedicated issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants