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

KeyError raised on views.stats view when using Redis Sentinel #672

Open
alaouimehdi1995 opened this issue Sep 3, 2024 · 6 comments
Open

Comments

@alaouimehdi1995
Copy link
Contributor

When using Sentinels connection to Redis instead of a "single host", when opening the /admin/background-tasks/ URL, the following exception is raised:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/views/decorators/cache.py", line 62, in _wrapper_view_func
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django_rq/views.py", line 37, in stats
    **get_scheduler_statistics(),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django_rq/utils.py", line 106, in get_scheduler_statistics
    conn_key = f"{connection['host']}:{connection.get('port', 6379)}/{connection.get('db', 0)}"
                  ^^^^^^^^^^^^^^^^^^

Exception Type: KeyError at /admin/background-tasks/
Exception Value: 'host'
@spapas
Copy link

spapas commented Oct 10, 2024

Hello friends, I've got exactly the same problem (my redis listens on a unix socket). Any idea when a new version fixing this would be released ?

TIA

@spapas
Copy link

spapas commented Oct 10, 2024

Unfortunately, the fix at https://github.com/rq/django-rq/pull/671/files doesn't cover my case (as I said I connect to redis with unix sockets).

A single fix would be to allow a None host like this: master...spapas:django-rq:master

If you want I'd be happy to create a small PR for that.

@spapas
Copy link

spapas commented Dec 2, 2024

Hello friends, it's been two months and haven't got any reply to the problem. This is a 1 minute , 1 line fix.

To help you I have provided a PR #687 for that. But the PR needs to be merged and most importantly do a new release...

Can somebody please help ?

@MarcinWieczorek
Copy link

@selwin can you please apply PR #671 to pre RQ v2 branch (that is - on top of v2.10.3)? I need this fix but I'm not ready to migrate to v3.0 yet. Thank you

@spapas
Copy link

spapas commented Dec 2, 2024

Pls notice that the PR #671 will not fix my issue because I don't use a sentinel. I use a unix socket to connect to redis so there's no HOST that's why I need #687. TIA

@MarcinWieczorek
Copy link

I understand your case, I hope your issue is fixed as well.

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

3 participants