From 682c9fffd1cea0203140ba3816057a241e029c88 Mon Sep 17 00:00:00 2001 From: Nimisha Asthagiri Date: Thu, 17 Jul 2014 21:11:20 -0400 Subject: [PATCH 1/2] fix bulk_write context manager. --- common/lib/xmodule/xmodule/modulestore/mixed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mixed.py b/common/lib/xmodule/xmodule/modulestore/mixed.py index 7dfe0f345c..3ee379febd 100644 --- a/common/lib/xmodule/xmodule/modulestore/mixed.py +++ b/common/lib/xmodule/xmodule/modulestore/mixed.py @@ -497,8 +497,8 @@ def store_bulk_write_operations_on_course(store, course_id): # request comes in for the same course. # if the caller passed in the mixed modulestore, get a direct pointer to the underlying store - if hasattr(store, '_get_modulestore_by_course_id'): - store = store._get_modulestore_by_course_id(course_id) + if hasattr(store, '_get_modulestore_for_courseid'): + store = store._get_modulestore_for_courseid(course_id) try: if hasattr(store, 'begin_bulk_write_operation_on_course'): From a501aa9400d235edf2a774835aef9fa92fb8c508 Mon Sep 17 00:00:00 2001 From: Nimisha Asthagiri Date: Thu, 17 Jul 2014 17:24:52 -0400 Subject: [PATCH 2/2] don't update ancestors while bulk editing. Conflicts: common/lib/xmodule/xmodule/modulestore/mongo/base.py --- .../lib/xmodule/xmodule/modulestore/mongo/base.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index 7ae03cc332..267ce2362d 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -405,6 +405,13 @@ class MongoModuleStore(ModuleStoreWriteBase): self.ignore_write_events_on_courses.remove(course_id) self.refresh_cached_metadata_inheritance_tree(course_id) + def _is_bulk_write_in_progress(self, course_id): + """ + Returns whether a bulk write operation is in progress for the given course. + """ + # check with branch set to None + return course_id in self.ignore_write_events_on_courses + def _fill_in_run(self, course_key): if course_key.run is not None: return course_key @@ -552,7 +559,7 @@ class MongoModuleStore(ModuleStoreWriteBase): If given a runtime, it replaces the cached_metadata in that runtime. NOTE: failure to provide a runtime may mean that some objects report old values for inherited data. """ - if course_id not in self.ignore_write_events_on_courses: + if not self._is_bulk_write_in_progress(course_id): # below is done for side effects when runtime is None cached_metadata = self._get_cached_metadata_inheritance_tree(course_id, force_refresh=True) if runtime: @@ -1033,7 +1040,10 @@ class MongoModuleStore(ModuleStoreWriteBase): # update subtree edited info for ancestors # don't update the subtree info for descendants of the publish root for efficiency - if (not isPublish) or (isPublish and is_publish_root): + if ( + (not isPublish or (isPublish and is_publish_root)) and + not self._is_bulk_write_in_progress(xblock.location.course_key) + ): ancestor_payload = { 'edit_info.subtree_edited_on': now, 'edit_info.subtree_edited_by': user_id