Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The restoration process has two steps: find the ID of the correct version, and then tell modulestore to point the course run at that version.

1. Find the correct version via

...

Django Admin and MongoDB shell

...

Currently, there’s no easy way to introspect course run versions via Studio. So, we need to dive into a MongoDB shell. Ideally, this shell should be read-only, as we don’t want to be making any edits to Mongo here by accident.

...

.

For this context you can understand courses to be stored as documents. The modulestore is “split“ it uses two different DB services. We store the “document“ version of a course in MongoDB. Using MySql, we keep a ledger which for each course run, which notes the address of active published and draft versions' documents.

So, we can look at that ledger’s history to figure out which version we want to roll back to.

For this part, you need to have the App Permission cms_course_index_operator. Once you have that permission for the relevant environment, you can then view the Studio Django Admin page for the relevant environment. Select the `split_modulestore_django` tab, and search for your course run using the search tab.

Clicking on the course run will give you the current entry in the ledger. From that page, you can click on the “history“ button in the top right to view all previous versions of this ledger.

You can choose to roll back to a date from here if you so choose, but you might also want to inspect the course structure for a particular entry. That might be a process you complete alongside a support person, who will deem a rollback “acceptable“ or not. Luckily, you are equipped with the unique ids of each document for each version of you course.

In order to find the documents themselves to inspect them, Log into the Read Replica and run /edx/bin/prod-edx-edxapp-mongo.sh (substituting prod for stage or edx for edge as necessary).

Once in the shell, run use edxapp. Then, copy this entire script in, substituting in the correct values for ORG, COURSE, and RUN at the top.

...

languagejs

...

that shell, run db.modulestore.structures.

...

find

...

(

...

{

...

"

...

_id

...

"

...

You should see an output something like this:

Code Block
> examineAllAvailableVersions(latestCourseStructure);
Current version:
  version_guid = 5fbc16d7a9e30dc3e5a2eef4
  title        = Demonstration Course
  edited_on    = Mon Nov 23 2020 20:08:55 GMT+0000 (UTC)

1 version(s) back:
  version_guid = 5f19c8940ed7e0e9d7044419
  title        = Demonstration Course
  edited_on    = Thu Jul 23 2020 17:27:48 GMT+0000 (UTC)

2 version(s) back:
  version_guid = 5f19c8890ed7e0e9d7043a40
  title        = Demonstration Course
  edited_on    = Thu Jul 23 2020 17:27:37 GMT+0000 (UTC)

3 version(s) back:
  version_guid = 5f19c8890ed7e0e9d7043a3a
  title        = undefined
  edited_on    = Thu Jul 23 2020 17:27:37 GMT+0000 (UTC)

Showing all available (non-pruned) versions.

You can see here the different versions of the courses that exist in the Modulestore, along with their titles and creation dates.

Your goal here is to select the desired version. If you need more information, you can play with thegetLatestCourseStructure and lookBackNVersions functions yourself, each of which return big JSON documents detailing the structure of the course. This header comment that explains the DB structure of the Split modulestore may be useful to you.

Once you’ve chosen a version, make note of the version_guid you want to reset to, and use it in the next step: ObjectId("<OBJECT ID>")})

where <OBJECT ID> is the object id of a document you copy/paste from django admin. it will return a long json-esque document you/partner support can look at to determine if it acceptable for your course author.

2. Reset the course run to the correct version via the management command

There exists a management command to reset course content to different versions. It is implemented by reset_course_to_version in the Split modulestore. You may want to familiarize yourself a little bit with each of those before proceeding. Careful, there’s no confirmation prompt or anything.

Code Block
# Replace the course key with your course key
# and '5555aaaabbbbccccddddeeee' with your version_guid.
$ ./manage.py cms reset_course_content course-v1:ORG+COURSE+RUN 5555aaaabbbbccccddddeeee
... 
... (a ton of startup output)
...
Resetting 'course-v1:ORG+COURSE+RUN' to version '5555aaaabbbbccccddddeeee'...
...
... (a ton of signal handler / Celery output)
...
Done.

The command should run pretty quickly (<1s) and take effect immediately.

edXers: File an SRE support ticket and asking them to run this command for you, including the arguments.Making a rollback is easy once you have determined a particular version to be acceptable. Use the history button in django admin to find a version for a course, and click the “revert“ button and the bottom of the history entry to revert to that version. You can also manually enter the objectId values into the current entry if you so choose, if you wish for a bespoke combination. All that is required for that to work is for you to click “save“ at the bottom. NOTE THAT THE DRAFT AND PUBLISHED DOCUMENTS SHOULD NEVER BE THE SAME for an active entry!

Done?

Hopefully, that worked. All learner state should still safely be in the LMS, and should link back up to the restored content without any action. Huzzah!

...