One transaction per call to sql assignment backend

There are numerous schedules that lead to inconsistent data in the
various grant tables and role table. These races arose from a lack of
synchronization during grant table modification (i.e., during grant
record creation + deletion and role deletion) and deletions of records
that grant records refer to (i.e., user, group, domain, and project
records). The races manifested as 404 errors in response to API
requests. This patch adds the necessary synchronization by way of
transactions.

Also removed pointless session.flush() calls at the ends of transactions.

Closes-Bug: #1246489
Change-Id: I958d48bafc7fcb95f1d9ea71e408b4cefc2469c9
Merge "One transaction per call to sql assignment backend"