edx/edx-tim — pull request #183 by wedaly (2014-03-21 19:04:13+00:00)
Title: Index PeerWorkflowItem.assessment to avoid DB deadlock.

[TIM-370](https://edx-wiki.atlassian.net/browse/TIM-370)

`peer_assess` would sometimes 500 during concurrent requests while attempting to update `PeerWorkflowItem` scores, with this traceback: https://gist.github.com/wedaly/9677018

The root cause was a query that would select `PeerWorkflowItem`s for a particular set of assessments, then update them (confirmed by [MySQL debug info](https://gist.github.com/wedaly/9692879)).

To resolve this, I added an index for `PeerWorkflowItem.assessment`. This is basically a foreign key anyway (which defaults to -1), so indexing it makes sense. I've confirmed that this resolves the issue using the same concurrency test (a modified version of the perf test) that uncovered the issue to begin with.

@stephensanchez This involves a migration, so I'll need to coordinate this with your changes.