tasks_helper.py
69.2 KB
-
CohortMembership Transaction Fixes · 731d85f7
An issue arose recently due to ATOMIC_REQUESTS being turned on by default. It turns out that CohortMemberships had been somewhat relying on the old default transaction handling in order to keep CohortMemberships and the underlying CourseUserGroup.users values in-sync. To fix this, I've made all updates to Cohortmemberships go through an outer_atomic(read_committed=True) block. This, is conjunction with the already present select_for_update(), will no longer allow 2 simultaneous requests to modify objects in memory without sharing them. Only one process will be touching a given CohortMembership at any given time, and all changes will be immediately comitted to the database, where the other process will see them. I've also included some changes to get_cohort(), add_user_to_cohort(), and remove_user_from_cohort() in order to properly make use of the new CohortMembership system.
Eric Fischer committed