Can not run instructor tasks - celery error (unregistered task)

When running instructor tasks from the instructor dashboard, such as the ones in data download, the tasks never leave the “Queuing” state. Looking at the logs, I see this:

Mar  1 13:06:08 ip-(hidden) [service_variant=lms][lms.djangoapps.instructor_task.api_helper][env:sandbox] WARNING [ip-(hidden)  127660] [user 15] [ip (hidden)] [api_helper.py:90] - No duplicate tasks found: task_type profile_info_csv, task_key , and most recent task_id = 73
Mar  1 13:06:08 ip-(hidden) [service_variant=lms][celery.worker.consumer.consumer][env:sandbox] ERROR [ip-(hidden)  127631] [user None] [ip None] [consumer.py:497] - Received unregistered task of type 'lms.djangoapps.instructor_task.tasks.calculate_students_features_csv'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?

Please see
http://docs.celeryq.org/en/latest/internals/protocol.html
for more information.

The full contents of the message body was:
b'{"task": "lms.djangoapps.instructor_task.tasks.calculate_students_features_csv", "id": "a246ebfd-0b17-413d-9a69-928ed2bf8db8", "args": [74, {"xqueue_callback_url_prefix": "https://preview.lms.(hidden)", "request_info": {"username": "guipenedo", "user_id": 15, "ip": "(hidden)", "agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0", "host": "preview.lms.(hidden)"}, "task_id": "a246ebfd-0b17-413d-9a69-928ed2bf8db8"}], "kwargs": {}, "group": null, "group_index": null, "retries": 0, "eta": null, "expires": null, "utc": true, "callbacks": null, "errbacks": null, "timelimit": [null, null], "taskset": null, "chord": null}' (675b)
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/celery/worker/consumer/consumer.py", line 562, in on_task_received
    strategy = strategies[type_]
KeyError: 'lms.djangoapps.instructor_task.tasks.calculate_students_features_csv'

This happens for all tasks on the instructor dashboard, (example: lms.djangoapps.instructor_task.tasks.calculate_may_enroll_csv).
The tasks previously worked and I did not change anything celery related, at least afaik, so I am not quite sure why the task list is not being imported.
Any help would be appreciated.

1 Like

Solved by applying these changes Enforce a Celery singleton across cms and lms by using shared module by timmc-edx · Pull Request #25840 · edx/edx-platform · GitHub