edx/edx-tim — pull request #157 by ormsbee (2014-03-17 21:10:28+00:00)
Title: Fix integrity error on submission under repeatable-read mode.

@wedaly, @stephensanchez: hours of env set up today for fifteen minutes of bug squashing.

Shift the creation of the peer workflow to happen when overall
workflow is created, instead of implicitly creating it if it
doesn't exist while checking for workflow status. The problem was
that the read check happens in multiple places and AJAX requests
were hitting it at the same time. Because repeatable-read mode
prevents them from seeing each others work, a couple of threads
would find that the peer workflow did not exist and would try to
create it. This cause integrity errors because those constraints
are enforced, even if those rows aren't available to other
processes.

This should have been fixed no matter what, but it's important to
note that Django should never be run under MySQL's default
repeatable-read mode. Use read-committed. For legacy reasons,
edX's own servers are misconfigured in this respect.

[TIM-262]