r4fek / django-cassandra-engine

Django Cassandra Engine - the Cassandra backend for Django
BSD 2-Clause "Simplified" License
365 stars 85 forks source link

cassandra.cqlengine.CQLEngineException: Connection name '<object object at 0x7eff59dcc8e0>' doesn't exist in the registry. #82

Closed n1207n closed 7 years ago

n1207n commented 7 years ago

Hi! I'm experiencing an issue where django-cassandra-engine stops working due to new Cython version not being compatible with cassandra-driver python package. I looked around the web a bit, and it suggests to me that Cython version needs to be 0.24.1, as Cython 0.25 breaks the cassandra-driver.

Thankfully, Datastax team released a new version of cassandra-driver: 3.7.1, and Cython issue is gone but now I'm having a new issue.

All I can speculate from your code and cassandra-driver codebase is that your connection.get_session() no longer works as cassandra-driver's _connections dictionary is empty at the point of failure.

I spent the whole day to burn and crash therefore, any solution or advice would be really appreciated ;)

The below is the traceback from my Docker environment.

Thanks!!!

Traceback (most recent call last): File "/code/manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 353, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 327, in execute django.setup() File "/usr/local/lib/python2.7/site-packages/django/init.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "/usr/local/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/usr/local/lib/python2.7/site-packages/django_cassandra_engine/models/init.py", line 5, in conn.connect() File "/usr/local/lib/python2.7/site-packages/django_cassandra_engine/base/init.py", line 104, in connect self.connection = CassandraConnection(settings) File "/usr/local/lib/python2.7/site-packages/django_cassandra_engine/connection.py", line 58, in init** self.setup() File "/usr/local/lib/python2.7/site-packages/django_cassandra_engine/connection.py", line 62, in setup self.session = connection.get_session() File "/usr/local/lib/python2.7/site-packages/cassandra/cqlengine/connection.py", line 293, in get_session conn = get_connection(connection) File "/usr/local/lib/python2.7/site-packages/cassandra/cqlengine/connection.py", line 190, in get_connection raise CQLEngineException("Connection name '{0}' doesn't exist in the registry.".format(name)) cassandra.cqlengine.CQLEngineException: Connection name '<object object at 0x7eff59dcc8e0>' doesn't exist in the registry.

r4fek commented 7 years ago

Thanks for submitting the issue. I'll try to upgrade to the latest cassandra-driver soon.

danandersonasc commented 7 years ago

Also having this problem; FYI it is discussed here: https://datastax-oss.atlassian.net/browse/PYTHON-656 3.7.1 has the workaround.

n1207n commented 7 years ago

Notice that I have said that my environment has cassandra-driver==3.7.1.

Cython issue is gone, but now django-cassandra-engine is not compatible with new cassandra-driver.

n1207n commented 7 years ago

It's weird... Now django-cassandra-engine works again when I changed back to old pip dependencies.

It seems somehow my docker container is now using the last working Cython version. But please keep looking into this issue. cassandra-driver==3.7.1 may still conflict with django-cassandra-engine. I just wanted to make sure if this can be an issue for other people. That's all ;)

root@b7a273a98e1a:/code# pip freeze cassandra-driver==3.6.0 Django==1.9.9 django-allauth==0.27.0 django-cassandra-engine==0.11.1 django-cors-headers==1.1.0 django-debug-toolbar==1.5 django-rest-auth==0.8.1 djangorestframework==3.4.6 ecdsa==0.13 Fabric==1.12.0 futures==3.0.5 oauthlib==2.0.0 paramiko==1.17.2 pbr==1.10.0 psycopg2==2.6.2 pycrypto==2.6.1 python-openid==2.2.5 requests==2.11.1 requests-oauthlib==0.7.0 six==1.10.0 sqlparse==0.2.2 stevedore==1.17.1 virtualenv==15.0.2 virtualenv-clone==0.2.6 virtualenvwrapper==4.7.2

n1207n commented 7 years ago

Also based on what I've seen from my pip freeze command, Cython is not getting installed when installing cassandra-driver. I can only speculate that cassandra-driver is compiled without Cython extension or is compiled with Cython temporarily and gone.

If anyone else has some insights or similar errors, feel free to discuss :D

r4fek commented 7 years ago

Could you guys try now with current master?

n1207n commented 7 years ago

Hi @r4fek, I'm reloading the pip requirement with your github url instead of PyPi now. I'll get back to you once it's done.

n1207n commented 7 years ago

@r4fek I'm glad to confirm your fix is working!!!! Thanks for your attention and effort!

r4fek commented 7 years ago

I'm glad to hear that. I'll release corrected version soon.

bicepjai commented 4 years ago

this is happening again with these versions. anyone faced this issue and resolved it ?

cassandra-driver==3.24.0
Django==2.2
django-cassandra-engine==1.6.1

when starting the all and trying to get queryset

app_container       | Traceback (most recent call last):
app_container       |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
app_container       |     response = get_response(request)
app_container       |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
app_container       |     response = self.process_exception_by_middleware(e, request)
app_container       |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
app_container       |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
app_container       |   File "/app/app/views.py", line 14, in query_view
app_container       |     test_text = str(list(Storage_Keys_DCDF_GB.objects.all()))
app_container       |   File "/usr/local/lib/python3.8/site-packages/cassandra/cqlengine/query.py", line 437, in __len__
app_container       |     self._execute_query()
app_container       |   File "/usr/local/lib/python3.8/site-packages/cassandra/cqlengine/query.py", line 472, in _execute_query
app_container       |     self._result_generator = (i for i in self._execute(self._select_query()))
app_container       |   File "/usr/local/lib/python3.8/site-packages/cassandra/cqlengine/query.py", line 404, in _execute
app_container       |     result = _execute_statement(self.model, statement, self._consistency, self._timeout, connection=connection)
app_container       |   File "/usr/local/lib/python3.8/site-packages/cassandra/cqlengine/query.py", line 1531, in _execute_statement
app_container       |     return conn.execute(s, params, timeout=timeout, connection=connection)
app_container       |   File "/usr/local/lib/python3.8/site-packages/cassandra/cqlengine/connection.py", line 331, in execute
app_container       |     conn = get_connection(connection)
app_container       |   File "/usr/local/lib/python3.8/site-packages/cassandra/cqlengine/connection.py", line 241, in get_connection
app_container       |     raise CQLEngineException("Connection name '{0}' doesn't exist in the registry.".format(name))
app_container       | cassandra.cqlengine.CQLEngineException: Connection name '<object object at 0x7f88d52eaed0>' doesn't exist in the registry.
alfredn commented 3 years ago

+1 i'm witnessing the same exact scenario as @bicepjai has described

piecubed commented 3 years ago

Im also having this issue on python3.8

katherineobioha commented 3 years ago

Im also having this issue on python3.8

Can i see a copy of your database settings property? I had this issue, but when i put in the right host parameter it worked

asis99 commented 1 year ago

Hi i am trying to connect to cassandra using ORMs but it is giving me this error and i am using cassandra version cassandra-driver==3.24.0 and i am getting this error cassandra.cqlengine.CQLEngineException: Connection name '<object object at 0x000001E8B172B780>' doesn't exist in the registry.