Prevent inconsistent state for new review requests when things go wrong.

Review Request #8886 — Created April 6, 2017 and submitted

Review Board
If things go very wrong, a review request can end up in a half-created
state. A dangling DiffSetHistory might be created, or a review request
on a Local Site might not have a local ID. Chances of this are lessened
with some of the diff parsing improvements that are going in, but it's
still a possibility.

We now take a more careful approach to creating a review request.
Objects are created but not saved up-front. Once we know that everything
is in a good state, we begin saving all the objects needed for the
review request to the database. As a further improvement, we then also
grab just the new local ID from the database, rather than the entire
review request.

This should prevent us from ending up in any more situations where users
during high loads end up with broken review requests on Local Sites that
just lead to further crashes.

Unit tests pass.

Tested manually with a breakage on a Local Site. Didn't end up with a
broken review request.

  1. Ship It!
  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.5.x (7587f6c)