Skip to content

[BUG] Celery result backend default Redis DB number (0) does not match config default (1) #741

Description

@vipul674

Description of the Bug

There is a mismatch between the default Redis DB number for the Celery result backend in two places:

backend/app/celery_app.py (line ~7):

celery_app = Celery(
    "app.tasks",
    broker=os.getenv("CELERY_BROKER_URL", "redis://localhost:6379/0"),
    backend=os.getenv("CELERY_RESULT_BACKEND", "redis://localhost:6379/0"),  # ← DB 0
)

backend/app/config.py:

CELERY_RESULT_BACKEND: str = "redis://localhost:6379/1"  # ← DB 1

If CELERY_RESULT_BACKEND environment variable is set, both use it consistently. But if neither is set:

  • celery_app.py defaults to redis://localhost:6379/0 (DB 0)
  • config.py defaults to redis://localhost:6379/1 (DB 1)

This means Celery stores task results in Redis DB 0 while the rest of the application (and any monitoring tools) expect results in DB 1. The celery_app.py is imported and configured before config.py settings take effect in certain code paths.

Steps to Reproduce

  1. Start the application without setting CELERY_RESULT_BACKEND environment variable
  2. Submit a Celery task
  3. Check Redis DB 1 for the task result — it's empty
  4. Check Redis DB 0 — the result is stored there

Expected Behavior

Both defaults should use the same Redis DB number. The recommended fix is to align celery_app.py with config.py (use DB 1).

Affected File

backend/app/celery_app.py (line ~7)

Suggested Fix

Change the default in celery_app.py to match config.py:

backend=os.getenv("CELERY_RESULT_BACKEND", "redis://localhost:6379/1"),

Or better, import the default from config to ensure they never diverge.

GSSoC '26

  • Yes, I am participating in GirlScript Summer of Code and would like to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gssocGirlScript Summer of Code 2026 issue/PR

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions