don't update graders in submission save transaction

fixes CNVS-16263

this was causing database contention and deadlocks when many submissions for
a single assignment with several graders were updated at the same time.

test plan:
* with the rails cache enabled,
  create a course with an assignment and a student
* submit an assignment as the student
* as the teacher for the course, make sure the
  assignment shows up in the to-do list on the
  dashboard page
* verify that grading the submission updates the
  to-do list right away

Change-Id: I7ba30223d0099ce36007185008937fbb3ab498bd
Reviewed-on: https://gerrit.instructure.com/42735
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Simon Williams 2014-10-14 11:13:29 -06:00 committed by Cody Cutrer
parent 8ff922ff5f
commit d5b4d19334
1 changed files with 3 additions and 1 deletions

View File

@ -425,7 +425,9 @@ class Submission < ActiveRecord::Base
def touch_graders
if self.assignment && self.user && self.assignment.context.is_a?(Course)
User.where(id: self.assignment.context.admins).update_all(updated_at: Time.now.utc)
connection.after_transaction_commit do
User.where(id: self.assignment.context.admins).update_all(updated_at: Time.now.utc)
end
end
end