Merge pull request #23559 from edx/ormsbee/csm_write_optimization

Make XBlock views/handlers non-atomic requests.
This commit is contained in:
David Ormsbee
2020-04-01 11:02:46 -04:00
committed by GitHub
4 changed files with 8 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ from completion.models import BlockCompletion
from django.conf import settings
from django.contrib.auth.models import User
from django.core.cache import cache
from django.db import transaction
from django.http import Http404, HttpResponse, HttpResponseForbidden
from django.middleware.csrf import CsrfViewMiddleware
from django.template.context_processors import csrf
@@ -994,6 +995,7 @@ def xqueue_callback(request, course_id, userid, mod_id, dispatch):
@csrf_exempt
@xframe_options_exempt
@transaction.non_atomic_requests
def handle_xblock_callback_noauth(request, course_id, usage_id, handler, suffix=None):
"""
Entry point for unauthenticated XBlock handlers.
@@ -1008,6 +1010,7 @@ def handle_xblock_callback_noauth(request, course_id, usage_id, handler, suffix=
@csrf_exempt
@xframe_options_exempt
@transaction.non_atomic_requests
def handle_xblock_callback(request, course_id, usage_id, handler, suffix=None):
"""
Generic view for extensions. This is where AJAX calls go.

View File

@@ -273,8 +273,8 @@ class IndexQueryTestCase(ModuleStoreTestCase):
NUM_PROBLEMS = 20
@ddt.data(
(ModuleStoreEnum.Type.mongo, 10, 172),
(ModuleStoreEnum.Type.split, 4, 170),
(ModuleStoreEnum.Type.mongo, 10, 170),
(ModuleStoreEnum.Type.split, 4, 168),
)
@ddt.unpack
def test_index_query_counts(self, store_type, expected_mongo_query_count, expected_mysql_query_count):

View File

@@ -16,6 +16,7 @@ import six.moves.urllib.request # pylint: disable=import-error
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.views import redirect_to_login
from django.db import transaction
from django.http import Http404
from django.template.context_processors import csrf
from django.urls import reverse
@@ -95,6 +96,7 @@ TEMPLATE_IMPORTS = {'urllib': urllib}
CONTENT_DEPTH = 2
@method_decorator(transaction.non_atomic_requests, name='dispatch')
class CoursewareIndex(View):
"""
View class for the Courseware page.

View File

@@ -1613,6 +1613,7 @@ def _track_successful_certificate_generation(user_id, course_id):
@require_http_methods(["GET", "POST"])
@ensure_valid_usage_key
@xframe_options_exempt
@transaction.non_atomic_requests
def render_xblock(request, usage_key_string, check_if_enrolled=True):
"""
Returns an HttpResponse with HTML content for the xBlock with the given usage_key.