From 4c36a7dd4f2d91ae8254b51c8855ed953cb2d9b4 Mon Sep 17 00:00:00 2001 From: Muhammad Arslan Abdul Rauf Date: Thu, 1 Jan 2026 17:40:02 +0500 Subject: [PATCH] fix: update course apps status on transaction commit to avoid gettings stale data --- openedx/core/djangoapps/course_apps/handlers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/course_apps/handlers.py b/openedx/core/djangoapps/course_apps/handlers.py index fc932af71e..c116ffce65 100644 --- a/openedx/core/djangoapps/course_apps/handlers.py +++ b/openedx/core/djangoapps/course_apps/handlers.py @@ -1,6 +1,7 @@ """ Signal handlers for course apps. """ +from django.db import transaction from django.dispatch import receiver from opaque_keys.edx.keys import CourseKey from xmodule.modulestore.django import SignalHandler @@ -16,7 +17,9 @@ def update_course_apps(sender, course_key, **kwargs): # pylint: disable=unused- Whenever the course is published, update the status of course apps in the django models to match their status in the course. """ - update_course_apps_status.delay(str(course_key)) + # Adding transaction.on_commit to ensure that the course publish operations + # are fully complete before we attempt to read the course data. + transaction.on_commit(lambda: update_course_apps_status.delay(str(course_key))) # pylint: disable=unused-argument