From f3dab829fef39613c5d3b873c8809ba70fb9d196 Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Wed, 21 Feb 2024 13:19:53 -0400 Subject: [PATCH] fix: use non_atomic_requests decorator in handle_block view (#34020) --- cms/djangoapps/contentstore/views/block.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cms/djangoapps/contentstore/views/block.py b/cms/djangoapps/contentstore/views/block.py index 8d157c66c45b..e2d1572bc25b 100644 --- a/cms/djangoapps/contentstore/views/block.py +++ b/cms/djangoapps/contentstore/views/block.py @@ -6,6 +6,7 @@ from django.contrib.auth.decorators import login_required from django.core.exceptions import PermissionDenied +from django.db import transaction from django.http import Http404, HttpResponse from django.utils.translation import gettext as _ from django.views.decorators.http import require_http_methods @@ -74,6 +75,12 @@ ALWAYS = lambda x: True +# Disable atomic requests so transactions made during the request commit immediately instead of waiting for the end of +# the request transaction. This is necessary so the async tasks launched by the current process can see the changes made +# during the request. One example is the async tasks launched when courses are published before the request +# ends, which end up reading from an outdated state of the database. For more information see the discussion in the +# following PR: https://github.com/openedx/edx-platform/pull/34020 +@transaction.non_atomic_requests @require_http_methods(("DELETE", "GET", "PUT", "POST", "PATCH")) @login_required @expect_json