Add consolidation of duplicate LocalSiteProfile objects.

Review Request #12471 — Created July 14, 2022 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

We had two problems that were potentially causing the existence of
duplicate LocalSiteProfile models. The first of these is that this
wasn't using ConcurrencyManager, which handles integrity issues across
separate threads (or servers). The second, more difficult one, is that
some databases (particularly MySQL) were ignoring our unique_together
constraint when one of the relations was NULL. This meant it was
possible to end up with multiple LocalSiteProfile objects with
local_site=None.

This change moves us over to ConcurrencyManager, and implements a
check for the duplicate case when attempting to use
User.get_site_profile. If we do find duplicates, they'll be
consolidated into a single one before returning.

Ran unit tests.

Commits

Files