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.

Diff Revision 4 (Latest)

orig
1
2
3
4

Commits

First Last Summary ID Author
Add consolidation of duplicate LocalSiteProfile objects.
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. Testing Done: Ran unit tests.
a86e6b05cdefb853369e80ef04d5582c4db09faf David Trowbridge
reviewboard/accounts/managers.py
reviewboard/accounts/models.py
reviewboard/accounts/tests/test_local_site_profile.py
Loading...