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 2

This is not the most recent revision of the diff. The latest diff is revision 4. See what's changed.

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.
f75d2fa605a47d7485491004c54a5ae8a0f12905 David Trowbridge
reviewboard/accounts/managers.py
reviewboard/accounts/models.py
reviewboard/accounts/tests/test_local_site_profile.py
Loading...