Modulestore does not get course

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:

  1. Prepare the Org, Number and Run for the course we are going to create.
  2. 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.

  1. Create the course in studio.

  2. 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.

  3. Check mongo to make sure it is there.

use edxapp

db.modulestore.active_versions.find({"search_targets.wiki_slug": "ORG.NUMBER.RUN"})
  1. 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'")

@jacatove, I don’t know how cms-shell caches the courses, but it’s always been like this. However, these Celery tasks are likely failing due to race conditions.

If you add time.sleep(10) above this line, you should no longer see this error in the Celery task that generates the Course Outline (cms.djangoapps.contentstore.tasks.update_outline_from_modulestore_task).

I also see these errors in our Celery logs, but it happens only when a new course is created; these tasks work properly for re-running the courses. A newly created course has no content, so I believe it’s not a big deal - these tasks will run again once you add some content to the course and publish it.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.