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

Unrecoverable error in Celery worker: ReadOnlyError with Redis backend #624

Open
sklyar61 opened this issue Jun 22, 2023 · 0 comments
Open

Comments

@sklyar61
Copy link

Hello,

I'm experiencing an issue with my Celery worker intermittently shutting down due to a ReadOnlyError when trying to write to my Redis instance. Here's the error message I'm seeing:

[2023-06-22 12:38:52,599: CRITICAL/MainProcess] Unrecoverable error: ReadOnlyError("You can't write against a read only replica.")

This seems to be happening when my Redis instance goes into a read-only mode during sync.

I am using the following setup:

  • Python 3.8
  • Celery 5.2.7
  • Django-redis 5.2.0

My docker-compose.yml for Redis is as follows:

redis:
image: redis:latest
command: ["redis-server", "--maxmemory 300mb", "--maxmemory-policy allkeys-lru"]
ports:
- "6379:6379"

And my Celery configuration in Django settings is:

CELERY_BROKER_URL = 'redis://redis:6379/0'
CELERY_RESULT_BACKEND = 'redis://redis:6379/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'

I'm currently mitigating the issue by configuring my docker-compose to restart the Celery worker when it stops, but this is not a long-term solution. Is there a way to handle this ReadOnlyError within Celery, or to prevent Redis from going into read-only mode in the first place?

Thank you in advance for your help and suggestions.

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

1 participant