Once a course is created in studio the course_published signal is emitted, therefore some receivers trigger some async tasks which end up failing because the modulestore does not get the already created course.
The following procedure will demonstrate the issue:
- Prepare the Org, Number and Run for the course we are going to create.
- Get in the cms shell and execute this code.
from xmodule.modulestore.django import modulestore
from opaque_keys.edx.keys import CourseKey
modulestore().get_course(CourseKey.from_string('course-v1:ORG+NUMBER+RUN))
you won’t get anything since we haven’t created anything yet.
-
Create the course in studio.
-
Use the cms shell in step 2 and execute
modulestore().get_course(CourseKey.from_string('course-v1:ORG+NUMBER+RUN))
again. It returns NOTHING!. Reimporting the modulestore makes no difference. -
Check mongo to make sure it is there.
use edxapp
db.modulestore.active_versions.find({"search_targets.wiki_slug": "ORG.NUMBER.RUN"})
- Close the cms shell and repeat step 2. Now you get the course when doing
modulestore().get_course(CourseKey.from_string('course-v1:ORG+NUMBER+RUN))
I think something similar is happening with the cms-worker when doing the tasks because its modulestore for some reason is not “updated”. Has anyone experienced this?
Notes:
- Tested in nutmeg and olive.
- Tested in kubernetes and single server installation.
- Some errors are of this kind:
Task cms.djangoapps.contentstore.tasks.update_outline_from_modulestore_task[78fa194f-077b-4b9b-b1f1-be2143279345] raised unexpected: AttributeError("'NoneType' object has no attribute 'get_children'")
cms.djangoapps.contentstore.tasks.update_search_index[8bba4888-67f6-4bae-8336-807f31ddfe2e]: Search indexing error for complete course course-v1:AWS+EDD5+2023 - Error(s) present during indexing - ['General indexing error occurred']
ERROR/ForkPoolWorker-7] Indexing error encountered, courseware index may be out of date course-v1:ORG+NUMBER+RUN - AttributeError("'NoneType' object has no attribute 'id'")