Skip to content

feat: add name parameter to shared task for archiving room messages#928

Open
kallilsouza wants to merge 1 commit intomainfrom
fix/start-archive-rooms-messages-celery-beat
Open

feat: add name parameter to shared task for archiving room messages#928
kallilsouza wants to merge 1 commit intomainfrom
fix/start-archive-rooms-messages-celery-beat

Conversation

@kallilsouza
Copy link
Copy Markdown
Contributor

What

Added an explicit name parameter to the start_archive_rooms_messages Celery task decorator, changing it from @shared_task(queue="archive-chats") to @shared_task(name="start_archive_rooms_messages", queue="archive-chats").

Why

The task was registered in CELERY_BEAT_SCHEDULE with the short name "start_archive_rooms_messages", but without an explicit name in the decorator, Celery auto-generates the task name using the full module path (chats.apps.archive_chats.tasks.start_archive_rooms_messages). This mismatch caused Celery Beat to send messages with an unrecognized task name, resulting in NotRegistered errors on workers and the task never executing in production.

This fix aligns with the existing pattern used by the process_pending_reports task, which already sets name="process_pending_reports" explicitly.

Sequence diagram

sequenceDiagram
    participant Beat as Celery Beat
    participant Broker as Redis Broker
    participant Worker as Celery Worker

    Note over Beat,Worker: Before fix
    Beat->>Broker: Send task "start_archive_rooms_messages"
    Broker->>Worker: Deliver task
    Worker--xWorker: NotRegistered (only knows "chats.apps.archive_chats.tasks.start_archive_rooms_messages")

    Note over Beat,Worker: After fix
    Beat->>Broker: Send task "start_archive_rooms_messages"
    Broker->>Worker: Deliver task
    Worker->>Worker: Match task by explicit name="start_archive_rooms_messages"
    Worker->>Worker: Execute start_archive_rooms_messages()
    Worker->>Broker: Dispatch archive_room_messages subtasks (queue: archive-chats)
Loading

@kallilsouza kallilsouza changed the title feat: rename shared task for archiving room messages feat: add name parameter to shared task for archiving room messages Mar 27, 2026
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

Successfully merging this pull request may close these issues.

3 participants