Opened 13 years ago
Closed 13 years ago
#17918 closed Bug (fixed)
Sporadic proxy deletion failures on mysql
Reported by: | Nate Bragg | Owned by: | Nate Bragg |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.4-beta-1 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When running:
regressiontests.delete_regress.tests.ProxyDeleteTest
and regressiontests.delete_regress.tests.ProxyOfProxyDeleteTest
sporadic IntegrityError
s would occur. This was caused by the proxy model's base model not having the proxy model as a dependancy, and the sporadic nature was entirely the result of dictionary ordering going into Collector.sort() - sometimes it would be in an order that honored the constraints, sometimes it wouldn't.
This was introduced, I believe, in revision 17664. I have only observed it on mysql, but it is hypothetically a universal issue.
My proposed solution is simply to ensure that the proxy model's base class gets included as a dependency.
Thanks for the report!
I'm not actually able to reproduce the reported failures in the current proxy-delete tests using MySQL InnoDB. I've tried using Python 2.6 and 2.7, as well as the recent RC releases with hash randomization, using various hash seeds.
Nonetheless, on inspection of the deletion code I can verify the presence of the reported bug, and I'm able to construct a failing test case. I don't think the proposed fix is correct, as it relies on transitive dependencies through models not necessarily included in
data
(i.e. with none of their own instances being deleted), which the sort algorithm used doesn't handle.The right fix, I think, is to only include concrete models in the
dependencies
dictionary, and have proxy models represented by their concrete parent. This makes more sense, since thedependencies
dictionary represents database-level deletion-ordering dependencies, thus the real dependencies can only be between concrete models which have a database table.Proposed patch is at https://github.com/carljm/django/compare/master...t17918-proxy-delete-deps