Code

Opened 2 years ago

Closed 2 years ago

#17918 closed Bug (fixed)

Sporadic proxy deletion failures on mysql

Reported by: nate_b Owned by: nate_b
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 IntegrityErrors 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.

Attachments (1)

17918.patch (1.2 KB) - added by nate_b 2 years ago.

Download all attachments as: .zip

Change History (3)

Changed 2 years ago by nate_b

comment:1 Changed 2 years ago by carljm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 the dependencies 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

comment:2 Changed 2 years ago by carljm

  • Resolution set to fixed
  • Status changed from new to closed

In [17756]:

Fixed #17918 - Handle proxy models correctly when sorting deletions for databases without deferred constraints. Thanks Nate Bragg for the report.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.