remove transaction around saving scores

Removes a database transaction in the grade calculator that is scoped
around too much work.  The transaction was originally added before
postgres's upsert capability for two statements. Over time, more and
more work was added leading to deadlocks in production.

test plan:
 - spec pass

Change-Id: Ia95035be6934b148f8d836bf4419f978a0b45918
Reviewed-on: https://gerrit.instructure.com/212873
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Keith Garner <kgarner@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
This commit is contained in:
Keith T. Garner 2019-10-11 09:47:15 -05:00 committed by Keith Garner
parent 29ad554a27
commit 8aacb717cc
1 changed files with 7 additions and 13 deletions

View File

@ -427,19 +427,13 @@ class GradeCalculator
@course.touch
save_scores_in_transaction
end
def save_scores_in_transaction
Score.transaction do
@course.shard.activate do
save_course_and_grading_period_scores
save_course_and_grading_period_metadata
score_rows = group_score_rows
if @grading_period.nil? && score_rows.any?
dropped_rows = group_dropped_rows
save_assignment_group_scores(score_rows.join(','), dropped_rows.join(','))
end
@course.shard.activate do
save_course_and_grading_period_scores
save_course_and_grading_period_metadata
score_rows = group_score_rows
if @grading_period.nil? && score_rows.any?
dropped_rows = group_dropped_rows
save_assignment_group_scores(score_rows.join(','), dropped_rows.join(','))
end
end
end