Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make course -> lib import synchronous #34030

Merged

Conversation

connorhaugh
Copy link
Contributor

@connorhaugh connorhaugh commented Jan 9, 2024

Description

On an openedx platform with async workers enabled,

If a course author uploads a course which references some library that exists already on the platform, they run into errors.

This is because xml_importer makes an async call to spawn the import of the content from the library

And then it proceeds to attempt to copy & publish the library content block's children, which leads to the likely state where the celery task has not copied in the LCB's new children, and this means that the publish cannot see the children, and fails.

In order to fix this, I am making the call to sync_from_library an apply call, not a delay call, so that it operates synchronously until we figure out a long-term solution.

Supporting information

https://2u-internal.atlassian.net/browse/TNL-11339
#34029

# TODO: This task is synchronous until we can figure out race conditions with import
# These race conditions lead to failed imports of library content from course import.
# See: TNL-TNL-11339, https://github.com/openedx/edx-platform/issues/34029 for more info.
library_tasks.sync_from_library.apply(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.celeryq.dev/en/latest/reference/celery.app.task.html is how you know apply is the method to use.

Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion, but you if apply this and tests pass then LGTM.

xmodule/library_tools.py Outdated Show resolved Hide resolved
connorhaugh and others added 2 commits January 9, 2024 14:37
@connorhaugh connorhaugh merged commit 2b47b8a into master Jan 9, 2024
64 checks passed
@connorhaugh connorhaugh deleted the 2u/connorhaugh/feat-make-lib-upgrade-synchronous branch January 9, 2024 20:54
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

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