Upgrade issue - PG duplicate key value violates unique constraint "index_course_scores"

14 views
Skip to first unread message

Josh Kraemer

unread,
Apr 16, 2018, 11:53:30 AM4/16/18
to Canvas LMS Users
Hi,

We recently updated a Canvas installation that was 1 year behind Canvas production releases. All of the migrations and background tasks appear to have run successfully. When we try to add a student to a section (through API and UI), we get the following error:

PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_course_scores"
DETAIL:  Key (enrollment_id)=(25172) already exists.
: INSERT INTO "scores" ("enrollment_id", "current_score", "final_score", "created_at", "updated_at", "course_score", "unposted_current_score", "unposted_final_score", "current_points", "unposted_current_points", "final_points", "unposted_final_points") VALUES (25172, 76.67, 7.67, '2018-04-12 22:54:06.943588', '2018-04-12 22:54:06.943588', 't', 76.67, 7.67, 76.67, 76.67, 7.67, 7.67) RETURNING "id" caused by ERROR:  duplicate key value violates unique constraint "index_course_scores"
DETAIL:  Key (enrollment_id)=(25172) already exists.

This error occurs for most students that have existing enrollments/sections. It does not occur for new students and enrollments. Postgres says it can't insert the new enrollment record, but the ID it's trying to insert doesn't exist anywhere in the enrollments or scores table.

I noticed that the upgrade populated 4+ score records in the scores table for every existing enrollment.

My thought is that a background job (such as a DataFixUp) failed to finish successfully or that the index_course_scores is corrupt on the scores table.

Thoughts?
Reply all
Reply to author
Forward
0 new messages