Merge lp:~lamont/maas/bug-1567176 into lp:~maas-committers/maas/trunk
Proposed by
LaMont Jones
Status: | Rejected |
---|---|
Rejected by: | MAAS Lander |
Proposed branch: | lp:~lamont/maas/bug-1567176 |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
224 lines (+103/-16) 4 files modified
src/maasserver/models/fabric.py (+32/-8) src/maasserver/models/space.py (+31/-8) src/maasserver/models/tests/test_fabric.py (+20/-0) src/maasserver/models/tests/test_space.py (+20/-0) |
To merge this branch: | bzr merge lp:~lamont/maas/bug-1567176 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Disapprove | ||
Mike Pontillo (community) | Needs Fixing | ||
Review via email: mp+291545@code.launchpad.net |
Commit message
Harden space/fabric creation to avoid duplicate names, even temporarily.
Description of the change
Harden space/fabric creation to avoid duplicate names, even temporarily.
To post a comment you must log in.
Unmerged revisions
- 4902. By LaMont Jones
-
restore CleanSave.save before the assertEqual.
- 4901. By LaMont Jones
-
Harden space/fabric creation to avoid duplicate names, even temporarily.
The crux of the issue here is that if postgres is enforcing unique=True on name, then (since many things are not done inside of transactions), then default names become a source of conflict (the default name relies on the id, which is not known until the commit succeeds, and multiple branches can be in the middle of the insert-and-update logic at the same time.)
Making everything that inserts a space or fabric be transactional would be a solution, but I believe it's an invasive one to consider.
If we don't have the database enforce uniqueness, then we get near-uniqueness from the very sorts of situations that we run into above (where two inserts of spaces _with_ names that are the same, happen to pass in the night and both succeed.) TBF, this is an extremely unlikely case. If we do hit it, then we have the situation where two users create spaces (with the same name), and then whoever updates next fails, even though they didn't change the name....